5
5
from compressor import CssCompressor , JsCompressor
6
6
from compressor .conf import settings
7
7
8
- # MINT_DELAY is an upper bound on how long any
9
- # value should take to be generated (in seconds)
10
- MINT_DELAY = 30
11
- DEFAULT_TIMEOUT = 300
12
-
13
8
register = template .Library ()
14
9
15
10
class CompressorNode (template .Node ):
@@ -25,13 +20,13 @@ def cache_get(self, key):
25
20
if (time .time () > refresh_time ) and not refreshed :
26
21
# Store the stale value while the cache
27
22
# revalidates for another MINT_DELAY seconds.
28
- self .cache_set (key , val , timeout = MINT_DELAY , refreshed = True )
23
+ self .cache_set (key , val , timeout = settings . MINT_DELAY , refreshed = True )
29
24
return None
30
25
return val
31
26
32
- def cache_set (self , key , val , timeout = DEFAULT_TIMEOUT , refreshed = False ):
27
+ def cache_set (self , key , val , timeout = settings . REBUILD_TIMEOUT , refreshed = False ):
33
28
refresh_time = timeout + time .time ()
34
- real_timeout = timeout + MINT_DELAY
29
+ real_timeout = timeout + settings . MINT_DELAY
35
30
packed_val = (val , refresh_time , refreshed )
36
31
return cache .set (key , packed_val , real_timeout )
37
32
@@ -47,8 +42,7 @@ def render(self, context):
47
42
if output is None :
48
43
try :
49
44
output = compressor .output ()
50
- # rebuilds the cache every 30 days if nothing has changed.
51
- self .cache_set (compressor .cachekey , output , 2591000 )
45
+ self .cache_set (compressor .cachekey , output )
52
46
except :
53
47
from traceback import format_exc
54
48
raise Exception (format_exc ())
0 commit comments