Closed DavidMeu closed 1 year ago
Can you elaborate on this more? Also, have you tried using Start
and Stop
or DeleteExpired
methods to evict expired items only when you need them to be evicted (e.g., when some background task finishes)?
There's the
Loader interface that is used to load/lazily initialize missing cache items.
Which is great. I just wish it to auto run when an item has expired.
Also, have you tried using Start and Stop or DeleteExpired methods to evict expired items only when you need them to be evicted (e.g., when some background task finishes)?
I have. Although this not exactly what I need. Can you please elaborate on that?
You can find more information on that on the README page:
Even though the cache.Start() method handles expired item deletion well, there may be times when the system that uses ttlcache needs to determine when to delete the expired items itself. For example, it may need to delete them only when the resource load is at its lowest (e.g., after midnight, when the number of users/HTTP requests drops). So, in situations like these, instead of calling cache.Start(), the system could periodically call cache.DeleteExpired():
Saw that. This is still not the paved path I need.
I need:
Auto cache refresh on expiration
i.e firing the loader func on expiration.
That sounds like a use case that's specific to your project and is out of scope of this library. I suggest you try combining DeleteExpired
/OnEviction
events and Get
/Set
.
We have an issue where there's a big latency in the cache reloading. So we wish users to not suffer from that and that the cache can serve them while there's a
Generally speaking it would be nice to have: