go-cache
go-cache copied to clipboard
An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.
There is no way to just change the key for an item. If I wanted to do this manually, I would have to use `Delete` and then `Add`, but upon...
The last tag v 2.1.0 is created by 2017/7/22; I know the core code not changed in last years,but a new tag means the project is activite;
The documentation of `Flush` states, that it deletes all items from the cache. When calling `Delete`, `onEvicted` is run. Combining these two pieces of knowledge I expected, that `onEvicted` would...
I have rewritten go-cache to generic one. Originally `Cache` has incrementing and decrementing methods, but any constraint doesn't allow types to be added and subtracted. I decided to implement the...
Question
Is there any reason for not using defer when unlocking mutex? ``` func (c *cache) Get(k string) (interface{}, bool) { c.mu.RLock() defer c.mu.RUnlock() // "Inlining" of get and Expired item,...
it looks like struct `cache` is unnecessary in the code. I notice the comment _// If this is confusing, see the comment at the bottom of New()_, but i didn't...
Replaces #128 Makes the cache generically typed using (as of yet not released) [go generics](https://go.dev/blog/generics-proposal), so clients code looks like: ``` c := cache.New[int](cache.DefaultExpiration, 0) c.Set("foo", 5, cache.DefaultExpiration) c.Increment("foo", 1)...
Partially addresses #5