Closed prathyushark closed 4 years ago
Hi Prathyusha,
Thanks for your interest!
This was a bug. If both max_size
and ttl
are used, when cache expires, something wrong happens. When passing the same argument as before to a cached user function, neither does my previous code update the cache, nor does it use the data stored in the cache any more. This is due to some incorrect logics when dealing with multithreading scenarios.
Resolved in v0.2.2. Now available at PyPI or GitHub Releases.
Thank you for approving this and releasing the latest version.
Hi, I am trying to use both max_size and ttl for my cache, but I see that once the cached element is evicted from the cache after the ttl, it is not being cached anymore. Using @cached(ttl=5) works as expected, the element is evicted after 5 seconds and after the next subsequent call, it is cached and retrieved from the cache for the next 5 seconds. But when I use @cached(max_size=5, ttl=5), after the element is evicted it does not cache the subsequent calls and all calls after that are hitting the function instead. For example, refer to the below code snippet:
Here is a test case, to make it easier: