Allow disabling the cache during development

Set "devel > cache > enabled" to false in config.yaml to disable the cache. Defaults to true.
This commit is contained in:
Gina Häußge 2015-04-22 09:45:25 +02:00
parent 2ce40c4847
commit 3f14fdb51b
2 changed files with 8 additions and 0 deletions

View file

@ -76,6 +76,11 @@ def cached(timeout=5 * 60, key=lambda: "view/%s" % flask.request.path, unless=No
logger.debug("Cache bypassed, calling wrapped function")
return f(*args, **kwargs)
# also bypass the cache if it's disabled completely
if not settings().getBoolean(["devel", "cache", "enabled"]):
logger.debug("Cache disabled, calling wrapped function")
return f(*args, **kwargs)
cache_key = key()
# only take the value from the cache if we are not required to refresh it from the wrapped function

View file

@ -237,6 +237,9 @@ default_settings = {
},
"devel": {
"stylesheet": "css",
"cache": {
"enabled": True
},
"virtualPrinter": {
"enabled": False,
"okAfterResend": False,