Key-Value Database 00:00:01 The cloakroom gives Ana a ticket Ana hands her coat to an attendant. Her ticket says where to find it. A key-value database uses the same bargain. Supply the exact key and the service returns the value associated with it. Alice is stored under user:1. One lookup by name returns Alice. counter did not exist, so it starts at 0 and becomes 1. Logging out removes the session at once, without waiting. The number printed on Ana's ticket is enough for retrieval. A question like “who owns a green coat?” needs another index or a scan. Design the keys around the questions you will actually ask. 00:00:38 The difference between a timer and a full room The shop sends Ana a login code. A timer limits how long the code is accepted. Separately, the shop's cache can run out of space, even while many keys are still within their lifetime. A code for Ana lives for 300 seconds. After 300 seconds a get returns nil, even though memory is free. When a new entry arrives and the cache is full, this policy samples keys and evicts an older-looking candidate. With noeviction, the write of d fails and c stays. An expiry time expresses validity. Eviction is a decision about memory. If losing a valid entry breaks checkout, choose durable storage or a recovery path before relying on an eviction policy. 00:01:20 Count two visitors at the same instant Give each of two shop servers an increment button. Both read the old total before either writes. The screen makes the mistake visible because two arrivals move the number only once. Both servers read 10. Each adds one and writes 11. One view is lost. Each command is one step on the server. They run one after the other: 11, then 12. A single server-side increment treats reading and changing that key as one operation. That guarantee covers the increment itself. Sending a welcome email for every counted visitor requires its own delivery rule. 00:01:55 Why another machine barely helps one popular coat A clustered store maps a key to a numbered slot and maps the slot to a machine. Think of moving a row of numbered lockers between attendants without reissuing all the coats. 16,384 slots are shared by three nodes. Say the key hashes to slot 8000. Node 2 owns it. A replica can take over a failed owner. With asynchronous replication, a recent acknowledged write may be missing after failover. To add a fourth node, about a quarter of the slots (4,096) move. The other keys stay where they are. Inspect the traffic for each key before adding machines. A single celebrity product keeps mapping to one owner after a rebalance, even when the total number of keys is evenly divided. 00:02:41 Ana leaves the shop Return to the login ticket. The browser holds an opaque identifier. The server looks it up for each request, so it can expire a session or revoke it independently of the browser. The server makes a random id, stores the session under it for 1,800 seconds and sends the id in a cookie. The cookie brings k9f back. One get finds the user, and the lifetime is renewed. After 30 quiet minutes the key is gone. The next request must log in. Remember the cloakroom test. If you can write down the ticket before you ask for the value, this interface is a good fit. Then specify what expiration, eviction and failover mean for your customer.