Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure Flask-Cache with infinite timeout

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

I'd like to never refresh the cache while the app is running. Is this possible, and if so how do I do it?

like image 393
iwein Avatar asked Jul 30 '13 05:07

iwein


2 Answers

Flask-Cache uses werkzeug.contrib.cache behind the scenes. From the documentation it's made clear that

A timeout of 0 indicates that the cache never expires.

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

like image 147
foob Avatar answered Oct 05 '22 11:10

foob


There does not seem to be anything listed in the docs. I have used the following and it works fine.

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

That is way more years than you will need to worry about so for all intents and purposes, let's call that infinite.

like image 27
Chiedo Avatar answered Oct 05 '22 09:10

Chiedo