hot
hot copied to clipboard
Unbounded cache (infinite capacity)
// NewLRUCacheWithEvictionCallback creates a new LRU cache with the specified capacity and eviction callback.
// The callback will be called whenever an item is evicted from the cache.
func NewLRUCacheWithEvictionCallback[K comparable, V any](capacity int, onEviction base.EvictionCallback[K, V]) *LRUCache[K, V] {
if capacity <= 0 {
panic("capacity must be greater than 0")
}
LRUCache accept capacity 0 but this checks blocking it, can we close this one?
[EDITED] I edit previous message because not show correct part
what is the point of having LRU cache with 0 capacity ?
Right, I just don't want to implement if capacity 0.
Is it possible than add an algorithm without doing eviction but still support TTL or not?
Hey @rytsh
Can you create a new Unbounded cache strategy ?
I think a b-tree or binary search tree should work fast. (or any O=log n algo)
Yes, I will be prepare something