Add lru-cache module: LinkedHashMap and hand-rolled DLL LRU, coarse-lock/striped thread-safe variants, broken ReadWriteLock demo, Caffeine reference, 43 tests, JMH harness

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4VQVEJWetTT1dYzyJ
This commit is contained in:
2026-10-29 05:52:27 +00:00
co-authored by Claude Sonnet 5.5
parent 4a376b94e9
commit 0457cf4bfb
31 changed files with 1425 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Regenerates every file in output/. Needs JDK 25 and Maven. First Maven run must be online.
# 01-08 are written by JUnit tests that assert the same facts (deterministic).
# 09 (broken ReadWriteLock demo) and 10 (JMH) are MEASUREMENTS: they vary per run and machine.
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p output
mvn -B -q -T1 test
mvn -B -q -T1 compile
{ java -cp target/classes com.ankurm.interviewlab.lrucache.BrokenLockDemo 2>&1 | grep -v '^Picked up JAVA_TOOL_OPTIONS' ; } > output/09-broken-readwritelock-demo.txt
scripts/run-jmh.sh > /dev/null
echo "done:"; ls -1 output