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
Before reporting a bug, please make sure you have the latest cachetools version installed:
pip install --upgrade cachetools
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 the popitem() can catch expiration from any class.
This does not work with TTLCache.
Expected result
Overriding popitem() should be called when an item is expired.
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.
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
The text was updated successfully, but these errors were encountered: