Settings

Theme

Ask HN: Designing TTL for a B-tree KV store – feedback on dual-index approach

github.com

4 points by swaminarayan 2 days ago · 1 comment

Reader

swaminarayanOP 2 days ago

Adding TTL to an embedded KV store (built on SQLite's B-tree layer, not SQL).

The constraint: TTL needs two conflicting access patterns – lookup by key (get expiry check) and scan by expiry time (efficient purge). Single index can't serve both. Using two hidden companion CFs to solve this.

Three open questions: 1. Transparent expiry on get() vs explicit TTL check – which is better UX? 2. Should purge_expired() accept a max_keys limit to bound transaction size? 3. Seconds vs milliseconds precision – is sub-second TTL ever needed?

Design doc: https://github.com/hash-anu/snkv/blob/adding_ttl/docs/propos...

For new devs, Current design doc: https://github.com/hash-anu/snkv/blob/adding_ttl/internal/KV...

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection