Core concepts
Persistence
Klyro keeps everything in RAM and snapshots the whole keyspace to a dump file. Saves are atomic, the format is versioned, and older dumps still load.
When a save happens
| Trigger | Notes |
|---|---|
| Graceful shutdown | SHUTDOWN, SIGINT, or SIGTERM — including docker stop |
| SAVE | Writes the dump immediately and replies OK |
| Autosave | Every save-interval seconds, but only if something changed |
On startup the dump file is loaded if it exists. Killing the process outright, a crash, or power loss loses everything since the last save, which is at most save-interval seconds of writes.
The dump format
The file is length-prefixed, because a value may contain a newline: a KLYRO-DUMP 3 header, then one record per key giving its type and absolute expiry, then each blob as its length followed by exactly that many bytes. Saves are written to <path>.tmp and renamed over the real path, so a crash mid-save cannot corrupt the existing dump.
A memory index writes its configuration and its records, never its inverted index or its vector array. Both are derivable, so they are rebuilt on load. That keeps the dump small and leaves one format to maintain rather than two.
Version 1 and 2 dumps still load, so an existing file survives the upgrade. They are rewritten as version 3 on the next save.
Operating it
In Docker
The image keeps the dump in the /data volume, so mount one:
docker stop sends SIGTERM, and Klyro saves before exiting. Compose allows 30 seconds for that; raise stop_grace_period if a large keyspace needs longer.
There is no append-only log and no replication in 0.1.1. If losing up to a minute of writes is unacceptable, lower save-interval, and treat the dump as what it is: a periodic snapshot, not a durable transaction log.
