https://github.com/kavicastelo/advanced-cache-design
A collection of advanced cache design algorithms including LRU, LFU, ARC, TinyLFU, Count-Min Sketch, and Segmented LRU, implemented in TypeScript.
https://github.com/kavicastelo/advanced-cache-design
arc-cache cache-design count-min-sketch lfu-cache lru-cache slru-cache system-design tinylfu
Last synced: 5 months ago
JSON representation
A collection of advanced cache design algorithms including LRU, LFU, ARC, TinyLFU, Count-Min Sketch, and Segmented LRU, implemented in TypeScript.
- Host: GitHub
- URL: https://github.com/kavicastelo/advanced-cache-design
- Owner: kavicastelo
- License: mit
- Created: 2025-11-18T17:18:13.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-11-18T18:17:04.000Z (7 months ago)
- Last Synced: 2025-11-18T19:17:26.600Z (7 months ago)
- Topics: arc-cache, cache-design, count-min-sketch, lfu-cache, lru-cache, slru-cache, system-design, tinylfu
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advanced Cache Design Algorithms (LRU, LFU, ARC, TinyLFU, SLRU, CMS)
This repository contains **production-quality, educational implementations** of modern cache eviction and admission algorithms used in systems such as:
- Redis
- ZFS
- Cloudflare CDN
- YouTube backend services
- Googleβs Caffeine Cache
- OS kernel memory managers
These implementations are written in **TypeScript**, focusing on clarity and correctness.
---
## π Included Algorithms
### βοΈ LRU (Least Recently Used)
Classical O(1) LRU using a doubly linked list + hash map.
### βοΈ LFU (Least Frequently Used)
Full LFU with frequency lists and O(1) updates.
### βοΈ ARC (Adaptive Replacement Cache)
Self-tuning hybrid of recency and frequency.
### βοΈ TinyLFU (Admission Policy)
Modern frequency-based admission algorithm used by Google Caffeine.
### βοΈ SLRU (Segmented Least Recently Used)
Two-tier LRU that protects hot entries from eviction.
### βοΈ CMS (Count-Min Sketch)
Probabilistic frequency estimator (used by huge-scale caches).
---
## π¦ Installation
```bash
git clone https://github.com/kavicastelo/advanced-cache-design.git
cd advanced-cache-design
npm install
```
---
## βΆοΈ Running Examples
```bash
npm run build
node dist/examples/test-lru.js
```
Want scripts for all algorithms? Just run:
```bash
node dist/examples/test-*.js
```
---
## π Directory Overview
```text
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
```
---
## π§° Technologies Used
- TypeScript
- Node.js
- Modern data structure design
- Systems design best practices
---
## π License
[MIT](LICENSE) License β Free to use and modify.