This repository contains production-quality, educational implementations of modern cache eviction and admission algorithms used in systems such as:
These implementations are written in TypeScript, focusing on clarity and correctness.
Classical O(1) LRU using a doubly linked list + hash map.
Full LFU with frequency lists and O(1) updates.
Self-tuning hybrid of recency and frequency.
Modern frequency-based admission algorithm used by Google Caffeine.
Two-tier LRU that protects hot entries from eviction.
Probabilistic frequency estimator (used by huge-scale caches).
git clone https://github.com/kavicastelo/advanced-cache-design.git
cd advanced-cache-design
npm install
npm run build
node dist/examples/test-lru.js
Want scripts for all algorithms? Just run:
node dist/examples/test-*.js
src/
lru/ → LRU cache implementation
lfu/ → LFU cache implementation
arc/ → ARC hybrid cache
cms/ → Count–Min Sketch
tiny-lfu/ → TinyLFU admission
slru/ → Segmented LRU eviction
examples/ → Demo scripts
MIT License – Free to use and modify.