You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cache works well, but I'm missing a feature: the ability to reset the expiry timer (in my case, MaxAge of 30 seconds) whenever an entry is retrieved. The current behavior is that entries become stale (eligible for cleanup/eviction) based on the initial time they were set, regardless of how often they're accessed.
Problem:
In my use case, I want the cached Kafka clients to only be evicted if they haven't been accessed for the duration specified by MaxAge. The current setup evicts items based on their initial creation time, which means even frequently accessed items are evicted after 30 seconds.
Proposal:
Introduce a new cache option, which can be added to reset the timer for an entry upon access/retrieval. This would basically allow a LRU cache. Usage could look like this:
// A configurable function where users specify what the new maxAge or maxErrorAge should be.cache.RefreshExpiryOnAccess(maxAge, maxErrorAgetime.Duration)
The text was updated successfully, but these errors were encountered:
Description:
I'm currently using the twmb/go-cache library to cache Kafka clients with the following settings:
The cache works well, but I'm missing a feature: the ability to reset the expiry timer (in my case, MaxAge of 30 seconds) whenever an entry is retrieved. The current behavior is that entries become stale (eligible for cleanup/eviction) based on the initial time they were set, regardless of how often they're accessed.
Problem:
In my use case, I want the cached Kafka clients to only be evicted if they haven't been accessed for the duration specified by
MaxAge
. The current setup evicts items based on their initial creation time, which means even frequently accessed items are evicted after 30 seconds.Proposal:
Introduce a new cache option, which can be added to reset the timer for an entry upon access/retrieval. This would basically allow a LRU cache. Usage could look like this:
The text was updated successfully, but these errors were encountered: