Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying CACHE_THRESHOLD does not have any effect until midnight #588

Open
guidocioni opened this issue Aug 2, 2024 · 0 comments
Open

Comments

@guidocioni
Copy link

I'm seeing a really strange behaviour where the CACHE_THRESHOLD value is only honoured exactly at midnight: at this time the cache is cleaned from old copies and only the number specified in CACHE_THRESHOLD survives.
During the rest of the day, instead, the cache grows indefinitely and the number of items surpasses the number set in CACHE_THRESHOLD, as shown by this disk usage graph on my server.

system-localhost-df_root-14d

Surely I'm interpreting the documentation wrong or doing something bad in my code, but I'm setting the cache as easily as this

from flask_caching import Cache

cache = Cache(config={"CACHE_TYPE": "filesystem",
                      "CACHE_DIR": cache_dir,
                      "CACHE_THRESHOLD": 20})

and decorating the functions with

@cache.memoize(240)
def get_radar_data(
    data_path=CACHE_DIR,
    base_radar_url=RADAR_URL,
):

Do you know what could be the issue?

Environment:

  • Python version: 3.12.3
  • Flask-Caching version: 2.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant