Merged in dziegler's changes, a dog pile prevention and a needed verison bump

This commit is contained in:
xian
2009-12-28 23:29:33 -06:00
2 changed files with 17 additions and 3 deletions

View File

@@ -23,8 +23,22 @@ class CompressorNode(template.Node):
if in_cache:
return in_cache
else:
output = compressor.output()
cache.set(compressor.cachekey, output, 86400) # Rebuilds the cache once a day if nothing has changed.
# do this to prevent dog piling
in_progress_key = 'django_compressor.in_progress.%s' % compressor.cachekey
in_progress = cache.get(in_progress_key)
if in_progress:
while cache.get(in_progress_key):
sleep(0.1)
output = cache.get(compressor.cachekey)
else:
cache.set(in_progress_key, True, 300)
try:
output = compressor.output()
cache.set(compressor.cachekey, output, 2591000) # rebuilds the cache every 30 days if nothign has changed.
except:
from traceback import format_exc
raise Exception(format_exc())
cache.set(in_progress_key, False, 300)
return output
@register.tag

View File

@@ -8,7 +8,7 @@ README = read('README.rst')
setup(
name = "django_compressor",
version = "0.5",
version = "0.5.1",
url = 'http://github.com/mintchaos/django_compressor',
license = 'BSD',
description = "Compresses linked and inline javascript or CSS into a single cached file.",