Hi,
I’m testing using the filesystem cache to increase an app’s performance (as per the example here). The code I’m using is something like this:
from flask_caching import Cache
cache = Cache(app.server, config={
'CACHE_TYPE': 'filesystem',
'CACHE_DIR': 'cache-directory'
})
@cache.memoize(timeout=TIMEOUT)
def query_data():
# This could be an expensive data querying step
return data.to_json(date_format='iso', orient='split')
def data():
return pd.read_json(query_data(), orient='split')
However, in my tests I’ve noticed that every time the timeout is hit and the query is done again a new version of the serialized file is generated in the cache directory, without the older one being removed.
Are these files deleted automatically after a set amount of time or do I need to clear them in the code (maybe adding cache.clean()
somewhere in the memoized function) ? What I’m worried about is that eventually the cache would grow too big and take up all the space available in the server.
Thanks!