Expand description
Cache state serialization and restoration.
Provides a binary serializer / deserializer so a cache can be persisted to disk on shutdown and quickly restored on startup — avoiding a cold-start penalty where all traffic misses until the cache is re-warmed organically.
§Wire format
The on-disk format is a simple length-prefixed binary encoding; no external serialization dependency is needed.
┌─────────────────────────────────────────────────────┐
│ MAGIC 8 bytes "OXICACHE" │
│ VERSION 2 bytes u16 LE = 1 │
│ FLAGS 2 bytes u16 LE (reserved, must be 0) │
│ N 4 bytes u32 LE number of entries │
│ ── per entry ────────────────────────────────────── │
│ key_len 4 bytes u32 LE │
│ key key_len bytes UTF-8 │
│ val_len 4 bytes u32 LE │
│ value val_len bytes raw bytes │
│ priority 4 bytes u32 LE │
│ ttl_secs 8 bytes u64 LE (0 = no TTL) │
└─────────────────────────────────────────────────────┘The format is intentionally simple and forward-compatible: unknown flags and trailing data are ignored on read.
Structs§
- Cache
Record - A single key-value record with optional metadata.
- Deserialize
Config - Configuration for the deserializer.
Enums§
- Serialize
Error - Errors returned by serialization / deserialization functions.
Functions§
- deserialize
- Read
CacheRecords fromreaderusing the defaultDeserializeConfig. - deserialize_
with_ config - Read
CacheRecords fromreaderwith an explicitDeserializeConfig. - load_
from_ file - Restore records from the file at
path. - load_
from_ file_ with_ config - Restore records from the file at
pathwith explicit limits. - save_
to_ file - Persist
recordsto the file atpath, creating or truncating it. - serialize
- Write a collection of
CacheRecords towriterin the OXICACHE binary format.