Back to problems

Implement a persistent sharded key-value store

Object-Oriented Programming · OpenAI · Medium

Approach 1: Live Map Backed by an Append-Only Log The shards are a write-ahead log split into segments, and every mutation turns into one self-delimiting text record that is appended to the tail of the newest segment. Nothing is ever rewritten in place, so the log is the single source of truth; the dictionary in memory is only a cache that makes reads instant. When the cache is thrown away, walking the log front to back reconstructs it exactly. A put is stored as P key…

Checking your access…