How to configure a cache flag with an infinite timeout

In the Flask-Cache documentation, all examples use a finite timeout.

I would never update the cache while the application is running. Is this possible, and if so, how can I do this?

+4
source share
2 answers

The key cache uses werkzeug.contrib.cache behind the scenes. From the documentation it was clear that

A timeout of 0 indicates that the cache never expires.

So yes, infinite caching is supported and can be enabled by setting the timeout to zero.

+2
source

The documents do not say anything. I used the following and it works great.

  cache = Cache(webapp, config={ 'CACHE_TYPE': 'filesystem', 'CACHE_DIR': 'cache-dir', 'CACHE_DEFAULT_TIMEOUT': 922337203685477580, 'CACHE_THRESHOLD': 922337203685477580 }) 

This is a lot more years than you will need to worry about it so, for all purposes and tasks, let me call it infinite.

+5
source

Source: https://habr.com/ru/post/1494191/


All Articles