muesli / cache2go

Concurrency-safe Go caching library with expiration capabilities and access counters
Other
2.11k stars 518 forks source link

PR to get cached value without updating it's keep alive #65

Open RatkoR opened 1 year ago

RatkoR commented 1 year ago

Hi,

we have a use case where we need to get cached value without touching it's keepAlive value. We need our cached item to expire at whatever time it was about to expire even if we pulled it's value this one time.

So I added a ValueOnly() function that works the same as CacheTable.Value(), but skips updating of keepAlive. In fact, I moved most of the code of the Value() function to new valueInternal() function and both (Value() and ValueOnly()) use it. It's like addInternal() or deleteInternal() that you also use.

Test case TestCacheExpire has been extended to cover the new function and all tests pass.

Please tell what would need to be changed also, to maybe get this additional function merged.

PR is here: https://github.com/muesli/cache2go/pull/64

RatkoR commented 1 year ago

Ahh, I see you already have a similar PR open: https://github.com/muesli/cache2go/pull/61/files. I'm fine if you merge #61 and close my PR.