Commit 089545ee by mattdennewitz Committed by Timothée Peignier

add configurable cache timeout value, default is 2 year.

Signed-off-by: Timothée Peignier <timothee.peignier@tryphon.org>
parent f5a902bf
......@@ -15,6 +15,8 @@ PIPELINE_VERSION_DEFAULT = getattr(settings, 'PIPELINE_VERSION_DEFAULT', '0')
PIPELINE_VERSION_REMOVE_OLD = getattr(settings, 'PIPELINE_VERSION_REMOVE_OLD', True)
PIPELINE_VERSIONING = getattr(settings, 'PIPELINE_VERSIONING', 'pipeline.versioning.mtime.MTimeVersioning')
PIPELINE_CACHE_TIMEOUT = getattr(settings, 'PIPELINE_CACHE_TIMEOUT', 63072000)
PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE',
'pipeline.storage.PipelineStorage')
......
......@@ -3,6 +3,8 @@ import os
from django.core.cache import cache
from django.dispatch import Signal, receiver
from pipeline.conf import settings
css_compressed = Signal(providing_args=["package", "version"])
js_compressed = Signal(providing_args=["package", "version"])
......@@ -12,4 +14,5 @@ js_compressed = Signal(providing_args=["package", "version"])
@receiver(js_compressed)
def invalidate_cache(sender, package, version, **kwargs):
filename_base, filename = os.path.split(package['output'])
cache.set("pipeline:%s" % filename, str(version))
cache.set("pipeline:%s" % filename, str(version),
settings.PIPELINE_CACHE_TIMEOUT)
......@@ -30,7 +30,7 @@ class Versioning(object):
if match and match.groups():
version = match.group(1)
break
cache.set("pipeline:%s" % filename, version)
cache.set("pipeline:%s" % filename, version, settings.PIPELINE_CACHE_TIMEOUT)
return str(version)
def output_filename(self, filename, version):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment