Create the Store

Step 1 — Create the Store

Build a basic key-value store class with a Python dict as the underlying storage.

You'll implement four methods:

  • put(key, value) — store a value
  • get(key) — retrieve a value, or None if missing
  • delete(key) — remove a key, return True if it existed
  • size() — number of keys

Once the tests pass, you'll have the minimal surface area of a KV store. The next steps add overwrite semantics, TTL, and an HTTP layer.

Hints
Starter code
class KeyValueStore:
    """A simple in-memory key-value store."""

    def __init__(self):
        # TODO: Initialize the underlying storage
        pass

    def put(self, key, value):
        """Store a key-value pair."""
        # TODO: Implement this
        pass

    def get(self, key):
        """Retrieve a value by key. Return None if not found."""
        # TODO: Implement this
        pass

    def delete(self, key):
        """Delete a key. Return True if deleted, False if not found."""
        # TODO: Implement this
        pass

    def size(self):
        """Return the number of keys in the store."""
        # TODO: Implement this
        pass
Write it on a laptop

The editor and the test runner need a wide screen. Open this page on a desktop browser and your progress will be waiting.