A key-value store associates each key with one value and retrieves that value through the key. The model handles direct lookups, such as finding Fiji’s capital, but not broad queries over many records. section 7.5.1
A practical store can represent keys and values as byte sequences of arbitrary length. The actionkv project begins with an in-memory command-line store and grows toward persistent storage that survives hardware failure. section 7.0 section 7.5.2
A Rust implementation demonstrates several core operations:
- Store and retrieve arbitrary byte sequences as key-value pairs. section 7.5.1
- Use HashMap indexing for fast direct access, or BTreeMap when ordered traversal and subsets are needed. section 7.7.9
- Handle missing keys with get(), which returns an Option, instead of indexing and risking a panic. section 7.7.9
- Persist records in files while coordinating library code, executable binaries, metadata, and storage dependencies through Cargo. section 7.5.2 section 7.7.6
Country capitals
A table can map "Fiji" to "Suva" and "Kiribati" to "South Tarawa". Looking up capitals["Tonga"] returns a read-only reference when the key exists; capitals.get("Tonga") allows the program to handle an absent key explicitly. section 7.5.1 section 7.7.9
Table 7.5 Illustrating keys and values by matching countries with their capital cities (view table figure)
Use the country-and-capital table to see direct lookup relationships between keys and values. section 7.5.1







