Skip to content

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

TriggerNotes
Graceful shutdownSHUTDOWN, SIGINT, or SIGTERM — including docker stop
SAVEWrites the dump immediately and replies OK
AutosaveEvery 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.

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

klyro
SAVE
+OK

CONFIG GET dbfilename save-interval
1) "dbfilename"     2) "klyro.dump"
3) "save-interval"  4) "60"

# Redirect the next save; the current file is left alone
CONFIG SET dbfilename /data/klyro-2.dump
+OK

SHUTDOWN
+OK

In Docker

The image keeps the dump in the /data volume, so mount one:

terminal
docker run -d -p 7171:7171 -v klyro-data:/data ghcr.io/hitesh-s0lanki/klyro:latest

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.