Commit 09d63b9
Asaad Balum
feat(cache): implement O(1) eviction policies and O(k) TTL cleanup
Addresses Issue #162:
Implementation:
- FIFO: Doubly-linked list queue for O(1) oldest entry selection
- LRU: Doubly-linked list + hashmap for O(1) least-recently-used tracking
- LFU: Frequency buckets with doubly-linked lists for O(1) least-frequently-used tracking
- ExpirationHeap: Min-heap for O(k) TTL cleanup (k = expired entries)
Performance (10k entries):
- FIFO SelectVictim: ~4.3 ns/op
- LRU SelectVictim: ~4.3 ns/op
- LFU SelectVictim: ~6.2 ns/op
Note: Issues 1 and 2 from #162 were already addressed in PR #347 and PR #504.
Signed-off-by: Asaad Balum <abalum@abalum-thinkpadp16vgen1.raanaii.csb>1 parent 6ace72a commit 09d63b9
File tree
2 files changed
+846
-44
lines changed- src/semantic-router/pkg/cache
2 files changed
+846
-44
lines changed
0 commit comments