Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

Launch price

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.

See plansStart free instead

Module 10 · System Design · Six more low-level rounds

Design an LRU cache (a map and a list that keep each other honest)

Design an LRU Cache
Design an LRU Cache · Open board

The desk and the file room, three eviction rules on the same twelve requests, the map and the list side by side, and the two follow-ups.

Before you start. You need two lessons. The object that keeps its own rules (encapsulation and invariants) showed an invariant: a promise about an object’s insides that every method must leave true, which is why the outside world never touches the insides. Design a parking lot (the first whole round) showed a whole round in order: ask, find the entities, sketch the classes, write the tricky part, take the follow-up, mention the lock. This lesson runs that round on a smaller problem with a sharper trap. You also need to read a little Python.

Lesson 45 of 73 in System Design

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1966: Belady and a memory too small to keep everything
  • The desk and the file room: cache and eviction
  • Which folder goes back: least recently used
  • Why a dictionary alone is not enough
  • The pile as a doubly linked list
  • A map and a list that keep each other honest

Terms it explains: invariant, cache, hit, miss, eviction, capacity, least recently used, LRU, O(1), hash map, doubly linked list, node, sentinel, LFU, lock.

Review System Design