Skip to content

Build an LRU Cache

Build the canonical O(1) LRU cache with a hash map + doubly-linked list. Then add TTL, sharding, metrics, and concurrency. By the end you'll understand caches in the kernel page cache, browser disk cache, Memcached, and Redis.

beginner8 lessons4 chapters8 graded exercisesPython

No sign-up needed for lesson 1 · certificate on completion · sign up to save progress

What you’ll have built

Chapter by chapter. Every step is a graded exercise.

  • Why LRU
  • The Doubly-Linked List + Hash Map
  • Concurrency
  • Variants & Production
Starts in Python — solve in the language you choose in the editor, same tests either way.

Curriculum

4 chapters, 8 lessons. Each lesson is a short read, one graded exercise, and a quiz.

  1. 1Why Caches?Read · exercise · quiz
  2. 2Naive LRU: List ScanRead · exercise · quiz
Loading reference solution…