An experimental TypeScript implementation of the SIEVE Cache algorithm — a modern cache replacement policy designed in 2023.
This project demonstrates how SIEVE works using Bun as the runtime and @axonlabs/core as the backend library for showcasing results.
SIEVE is a new cache algorithm created with the goal of being:
- ✅ Simpler than LRU (Least Recently Used)
- 🚀 Higher performing and more scalable
- 🎯 Improved hit rate and practical usability
Instead of using a tail pointer like LRU, SIEVE uses a "hand" pointer that walks through a Key-Value Doubly Linked Queue to decide which node to evict.
You can read full paper here: https://junchengyang.com/publication/nsdi24-SIEVE.pdf
Each cache entry (node) has a visited flag (0/1 or false/true):
-
Cache hit →
visited = true- Means the data was used at least twice.
- When the hand reaches it,
visitedwill be reset tofalse, and the hand moves forward.
-
Cache miss (insert new node)
- The hand traverses the queue.
- If it finds a node with
visited = false, that node gets evicted. - The new node is added to the head of the queue.
This mechanism makes SIEVE faster, leaner, and fairer compared to LRU.
- Language: TypeScript
- Runtime: Bun
- Backend: @axonlabs/core
# clone the repo
git clone https://github.com/Mr-MKZ/Sieve-Cache.git
cd Sieve-Cache
# install dependencies
bun installimport { SieveCache } from "./Sieve.ts";
// Create a cache with capacity 3
const cache = new SieveCache<number>(3);
cache.set("a", 1);
cache.set("b", 2);
cache.set("c", 3);
console.log(cache.get("a")); // hit → 1
cache.set("d", 4); // eviction triggered by SIEVERun with Bun:
bun run src/index.ts
or
bun startThis project includes integration with @axonlabs/core to benchmark and observe SIEVE behavior in a backend context.
| Feature | LRU | SIEVE |
|---|---|---|
| Eviction strategy | Remove tail node | Remove first unvisited node |
| Tracking overhead | Needs full order updates | Simple visited bit |
| Simplicity | Moderate | High |
| Hit rate (benchmarked) | Good | Often better |
| Real-world efficiency | Well-known but aging | New, promising |
MIT © 2025 — Built with ❤️ using TypeScript + Bun + AxonJs