Design key-value store

A key-value store, also referred to as a key-value database, is a non-relational database. Each unique identifier is stored as a key with its associated value. This data pairing is known as a “key-value” pair. In a key-value pair, the key must be unique, and the value associated with the key can be accessed through the key. Keys can be plain text or hashed values. For performance reasons, a short key works better. What do keys look like? Here are a few examples: • Plain text key: “last_logged_in_at” • Hashed key: 253DDEC4 The value in a key-value pair can be strings, lists, objects, etc. The value is usually treated as an opaque object in key-value stores, such as Amazon dynamo [1], Memcached [2], Redis [3], etc. Here is a data snippet in a key-value store:

In this chapter, you are asked to design a key-value store that supports the following operations:

  • put(key, value) // insert “value” associated with “key”

  • get(key) // get “value” associated with “key”

Last updated