go-generics-cache
go-generics-cache copied to clipboard
A key:value store/cache library written in Go generics. LRU, LFU, FIFO, MRU, Clock support.
Hi! Thanks for a good cache library that provides generics – it's really handy. I've used this a bit for certain things, and found out that adding an expiry to...
Example test: ``` cache := clock.NewCache[int, int](clock.WithCapacity(10)) for i := 0; i < 10; i++ { cache.Set(i, i) } cache.Set(10, 10) if len(cache.Keys()) != 10 { t.Errorf("want number of keys...
This adds a GetDefault method, which will either return the value in the cache, or if it is not present, set it with the passed-in value, returning whichever value ends...
Len() method is useful in common interface and is simple to implement. - implement Len for simple cache, it was the only policy missing the method Fixes https://github.com/Code-Hex/go-generics-cache/issues/43
It would be useful to have Len() method available in common interface. I would need it for getting metrics for cache usage. It is available if the cache is created...
Hii !! It would be greate to have data persistance. I would like to contribute to add save and load feature. I am thinking of using gob to save /...
Support KeepTTL option when update cache value. Fix Increment/Decrement lose expiration time.
- make sure that expManager queue is not empty before popping, which can happen if an explicit delete happens while DeleteExpired releases the lock. - evict() now returns shouldContinue instead...
https://github.com/Code-Hex/go-generics-cache/blob/2601bb0d3c67fc00cdbd5763cc2361d2a363f0ee/cache.go#L277-L279 After some pprof job, I believe this line make memory leaks as this would not checking lru cache capacity before doing heap push.
`ModifyFn` is a very handy function can be used to simulate `Increment/Decrement`,`Set`,`GetOrSet` or the added along `GetOrSetFn`. `GetOrSetFn` allows us to calculate the new value lazily, only if the cache...