Syllabus

Interview walkthrough: design a thread-safe LRU, start with LinkedHashMap, then harden locks, striping, and Caffeine-style reads.

The interview

The prompt lands. Clarify scope before you draw nodes.

  1. 1The Interview Prompt
  2. 2Clarify Requirements

Design

HashMap + doubly linked list, then the idiomatic LinkedHashMap answer.

  1. 3The Data Structure
  2. 4LinkedHashMap First

Concurrency

Correctness baseline, traps, JMM, compound ops, and explicit locks.

  1. 5Synchronized Baseline
  2. 6The ReadWriteLock Trap
  3. 7Java Memory Model
  4. 8Compound Operations
  5. 9ReentrantLock

Scale

Striping for throughput and Caffeine-style amortized recency.

  1. 10Segmented Locking
  2. 11Caffeine's Approach

Wrap-up

Say the answers out loud like an interview.

  1. 12Interview Questions