Closed mbrancato closed 2 months ago
The report seems related to https://github.com/tkem/cachetools/issues/205 and https://github.com/tkem/cachetools/issues/103
If it's not possible or planned to add a notification callback when an item is removed because expired in TTLCache, it could be useful to make it more explicit in the docs.
Thanks @GianlucaFicarelli for pointing to the closed issues!
This use case seems to be more popular than I thought, so I might think about it again.
Maybe expire()
returning a list of evicted keys, so you can override it in a derived class and act on the result of the base class method.
But don't expect anything too soon ;-)
But sure, the docs should definitely be improved in this respect.
Hello, I created this PR: https://github.com/tkem/cachetools/pull/320/files The goal of it is to perform some follow-up action when an element is going to expire, which is some how matching this use case. Let me know your thoughts
Before reporting a bug, please make sure you have the latest
cachetools
version installed:Describe the bug For extending a class, the docs say
all cache implementations call popitem() to evict items from the cache
and indicate that overriding thepopitem()
can catch expiration from any class.This does not work with
TTLCache
.Expected result Overriding
popitem()
should be called when an item is expired.Actual result The
popitem()
method is not called.Reproduction steps