A key-value store associates each key with a value so an application can save data and later load it by key. It suits persistence needs where direct lookup is the starting point, but storing and loading alone is not enough for many production scenarios: applications may also need transaction boundaries, several thread-safe connections, and a model that keeps database representation separate from business data. section 11.1 section 11.3
The smallest portable interface is deliberately narrow: save a raw key and value, then load a value that may be absent. Raw strings or byte arrays are common ground across stores, but they make correctness the caller’s responsibility. A successful load can still return bytes that business logic cannot interpret. section 11.2 section 11.3
A practical design separates common operations from storage-specific features:
- Keep the base interface focused on setting and getting values by key; a universal interface becomes unwieldy when it tries to expose every database-specific capability. section 11.1.1
- Represent transactional and nontransactional work explicitly when the application needs that distinction. section 11.1 section 11.3
- Use an untyped low-level layer for universal storage operations, then add a typed layer for domain-facing code. section 11.0 section 11.2
Typed meteor lookup
A meteor-tracking application can use a typed key constructor rather than passing arbitrary raw keys. `mkMeteorKey` produces a key specifically for meteor entities, and `loadEntity` loads raw database data and converts it to the requested result type. This keeps the database model free to use its own value representation while making entity-specific loading and parsing safe. section 11.2.3 section 11.3
A simulator can replace an external store with an in-memory map while preserving the storage role. For concurrent updates, an outer mutable map containing separately mutable values permits a single value to change without replacing the whole map, distributing control across threads more finely than a single locked map. section 8.2.2
Figure 11.4 Typed interface and database model
This diagram shows the boundary between raw key-value operations, a typed interface, and the database model used to connect storage representation with domain-facing code. section 11.2







