lonelyenvoy / python-memoization

A powerful caching library for Python, with TTL support and multiple algorithm options.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching repeated key after TTL not working

DrMatthewDunn opened this issue · comments

We have a challenging use-case involving creating animated countdown timers.
Timer animations are generated by a (separate) serverless function.
Timer definition is contained in the URL string - color, expiration date/time, and so on.

Caching of repeat requests with the -same- single param (the URL string) fails after the TTL.

@cached(ttl=10)
def fetch_count(url)
...
return image

fetch_counter(url)

cache hits mount up...but if, 15 seconds later...

fetch_counter(url)
fetch_counter(url)
fetch_counter(url)

according to cache_info(), there aren't any additional hits.
TTL clearing doesn't appear to expunge the key (url string in this case).

Workaround with clock value shouldn't be too difficult, just thought you'd want to know.

Rgds

Hi DrMatthewDunn,

Thanks for your interest!

This was a bug. For details, please read this issue. It's resolved in v0.2.2 and now available at PyPI or GitHub Releases.