Skip to content

The Redis-compatible layer (RESP) stores its data under first byte 0x10 (crates/strata-resp/src/keys.rs). Following that file, the layouts are:

Kind Key
meta 0x10 ‖ db u8 ‖ 'm' ‖ key
expiry 0x10 ‖ db u8 ‖ 'e' ‖ at u64 BE ‖ key
collection members 0x10 ‖ 0xFE ‖ gen u64 BE ‖ member parts
system: garbage 0x10 ‖ 0xFF ‖ 'g' ‖ gen u64 BE
system: key count 0x10 ‖ 0xFF ‖ 'c' ‖ db u8
system: ACL rule 0x10 ‖ 0xFF ‖ 'a' ‖ user utf8
system: generation counter 0x10 ‖ 0xFF ‖ 'n'

db is the database number (0 to 15), at is the expiry time and gen is a generation number. The spec does not describe the member parts beyond this.

The value of a meta key is kind|0x80 u8 ‖ expire u64 BE ‖ mtime u64 BE ‖ body. Kinds are 1 string, 2 hash, 3 list, 4 set, 5 zset, 6 stream. For a string the body is the raw value. For other kinds the body is gen u64 BE ‖ count u64 BE, plus a i64 BE ‖ b i64 BE for list, zset and stream. A first byte without bit 0x80 is the older form that has no mtime field.