thadeusb / flask-cache

Cache extension for Flask
http://packages.python.org/Flask-Cache/
Other
697 stars 185 forks source link

"forced_update" option to 'cache' and 'memoize' decorators #123

Closed alexey-sveshnikov closed 2 years ago

alexey-sveshnikov commented 9 years ago

Hi!

I implemented 'forced_update' option which accepts callable. If callable returns true memoized or cached decorators ignores any cached value regardless if it valid or not.

This option may be used to update cache for slow memoized functions in background jobs. At project that I maintain it helped me to resolve annoying problem of strong spikes of server load when cache for some heavy function expires and multiple web workers starts to calculate its value.

Fuyukai commented 9 years ago

Hi there, I've merged this in my fork of the repository at https://github.com/SkierPGP/flask-cache

tranlv commented 3 years ago

@alexey-sveshnikov Hi Alex, could you elaborate more on this option? when the cache is hit, shall it returns first => then update at the background?

alexey-sveshnikov commented 2 years ago

@tranlyvu, no I don't use this module anymore.