Memorust

Persistence (AOF)

How Memorust persists data with an Append Only File.

Memorust persists data using an Append Only File (AOF): every write command is appended to a log on disk. On startup, the log is replayed to rebuild the in-memory state.

How it works

  1. Append on write: write commands (such as SET, DEL, SETEX) are serialized and appended to the AOF.
  2. Buffered writer: writes go through a buffered writer to avoid a syscall per command.
  3. Periodic fsync: the buffer is flushed and fsync-ed roughly once per second, matching Redis's appendfsync everysec policy. This trades at most ~1 second of writes for much higher throughput.
  4. Replay on startup: when the server starts, it reads the AOF and replays the commands to restore the dataset.

AOF rewrite (compaction)

Over time the AOF accumulates redundant commands (for example, many SETs to the same key, or keys that were later deleted). The AOFREWRITE command compacts the log by rewriting it into the minimal set of commands needed to reproduce the current state:

AOFREWRITE

This keeps the on-disk file small and makes startup replay faster.

Trade-offs

The everysec strategy means a crash can lose at most about one second of writes. This is the same default Redis uses, and it is a deliberate balance between durability and write performance. See Benchmarks for the impact of the buffered writer.

On this page