Skip to content
StackDecode
System Design
7. Caching ArchitectureAnimated

Memcached

A simple, fast in-memory key-value cache.

The idea

Memcached stores strings by key across a pool of servers, with no persistence.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

N1N2N3N4N1: 6 keysN2: 11 keysN3: 11 keysN4: 2 keys
  • outlined = moved key

Nodes and keys are hashed onto the same ring. Each key belongs to the first node clockwise from it.

nodes:
4
keys:
30
moved:
0
1/2

Dots on the ring are keys; larger circles are servers.

Step by step

  1. 1Client hashes the key
  2. 2Chooses a server
  3. 3Gets or sets the value
  4. 4Expires entries by TTL

Where it is used

Simple caching.

Watch out for

No persistence or rich types.

Related