Documentation
¶
Overview ¶
Package persistence ties snapshots and the AOF to the engine: it loads data at startup, applies the "save" rules, runs BGSAVE / BGREWRITEAOF and flushes everything at shutdown. It implements command.Persister.
Index ¶
- Variables
- type Manager
- func (m *Manager) AOF() *aof.AOF
- func (m *Manager) AOFPath() string
- func (m *Manager) BgRewriteAOF() error
- func (m *Manager) BgSave() error
- func (m *Manager) Close(save bool) error
- func (m *Manager) Info() [][2]string
- func (m *Manager) LastSave() time.Time
- func (m *Manager) Save() error
- func (m *Manager) SnapshotPath() string
Constants ¶
This section is empty.
Variables ¶
var ErrBgSaveInProgress = errors.New("ERR Background save already in progress")
ErrBgSaveInProgress is returned by Save/BgSave while a background save runs.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// CronInterval is how often save rules and auto AOF rewrite are checked.
CronInterval time.Duration
// contains filtered or unexported fields
}
Manager implements command.Persister.
func Setup ¶
Setup loads the dataset (the AOF when appendonly is on and the file exists, otherwise the snapshot), opens the AOF and registers it as a propagator, sets e.Persist and starts the save-rules goroutine. Call it after command.New and before serving clients.
func (*Manager) BgRewriteAOF ¶
BgRewriteAOF compacts the AOF in the background (BGREWRITEAOF).
func (*Manager) BgSave ¶
BgSave starts a snapshot in the background (BGSAVE). The keyspace is only locked while it is serialised into memory; the disk write runs unlocked.
func (*Manager) Close ¶
Close stops background work and makes everything durable: waits for running saves/rewrites, writes a final snapshot if save is true, and flushes, fsyncs and closes the AOF. Call it at shutdown after the server stopped accepting commands.
func (*Manager) Save ¶
Save writes a snapshot synchronously (SAVE). It takes DB.LockAll itself, so it must not be called while holding shard locks.
func (*Manager) SnapshotPath ¶
SnapshotPath is dir/dbfilename.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package aof implements the append-only file: every write command is appended in RESP form (the same bytes a client sends), and replaying the file through the dispatcher rebuilds the dataset.
|
Package aof implements the append-only file: every write command is appended in RESP form (the same bytes a client sends), and replaying the file through the dispatcher rebuilds the dataset. |
|
Package snapshot implements cache-boy's binary point-in-time dump (the equivalent of Redis' RDB file).
|
Package snapshot implements cache-boy's binary point-in-time dump (the equivalent of Redis' RDB file). |