|
34 | 34 | from beaker.cache import cache_regions
|
35 | 35 | cache_regions.update({
|
36 | 36 | 'short_term':{
|
37 |
| - 'expire':'60', |
| 37 | + 'expire':60, |
38 | 38 | 'type':'memory'
|
39 | 39 | },
|
40 | 40 | 'long_term':{
|
41 |
| - 'expire':'1800', |
| 41 | + 'expire':1800, |
42 | 42 | 'type':'dbm',
|
43 | 43 | 'data_dir':'/tmp',
|
44 | 44 | }
|
@@ -130,7 +130,7 @@ def cache_region(region, *args):
|
130 | 130 | # configure regions
|
131 | 131 | cache_regions.update({
|
132 | 132 | 'short_term':{
|
133 |
| - 'expire':'60', |
| 133 | + 'expire':60, |
134 | 134 | 'type':'memory'
|
135 | 135 | }
|
136 | 136 | })
|
@@ -215,7 +215,7 @@ def region_invalidate(namespace, region, *args):
|
215 | 215 | # configure regions
|
216 | 216 | cache_regions.update({
|
217 | 217 | 'short_term':{
|
218 |
| - 'expire':'60', |
| 218 | + 'expire':60, |
219 | 219 | 'type':'memory'
|
220 | 220 | }
|
221 | 221 | })
|
@@ -256,7 +256,9 @@ def invalidate_search(self, search_term, limit, offset):
|
256 | 256 | region = cache_regions[region]
|
257 | 257 |
|
258 | 258 | cache = Cache._get_cache(namespace, region)
|
259 |
| - _cache_decorator_invalidate(cache, region['key_length'], args) |
| 259 | + _cache_decorator_invalidate(cache, |
| 260 | + region.get('key_length', util.DEFAULT_CACHE_KEY_LENGTH), |
| 261 | + args) |
260 | 262 |
|
261 | 263 |
|
262 | 264 | class Cache(object):
|
@@ -518,9 +520,10 @@ def load(search_term, limit, offset):
|
518 | 520 |
|
519 | 521 | cache = self.get_cache(namespace, **kwargs)
|
520 | 522 | if hasattr(func, '_arg_region'):
|
521 |
| - key_length = cache_regions[func._arg_region]['key_length'] |
| 523 | + cachereg = cache_regions[func._arg_region] |
| 524 | + key_length = cachereg.get('key_length', util.DEFAULT_CACHE_KEY_LENGTH) |
522 | 525 | else:
|
523 |
| - key_length = kwargs.pop('key_length', 250) |
| 526 | + key_length = kwargs.pop('key_length', util.DEFAULT_CACHE_KEY_LENGTH) |
524 | 527 | _cache_decorator_invalidate(cache, key_length, args)
|
525 | 528 |
|
526 | 529 |
|
@@ -560,9 +563,10 @@ def cached(*args):
|
560 | 563 | except UnicodeEncodeError:
|
561 | 564 | cache_key = " ".join(map(unicode, deco_args + args))
|
562 | 565 | if region:
|
563 |
| - key_length = cache_regions[region]['key_length'] |
| 566 | + cachereg = cache_regions[region] |
| 567 | + key_length = cachereg.get('key_length', util.DEFAULT_CACHE_KEY_LENGTH) |
564 | 568 | else:
|
565 |
| - key_length = kwargs.pop('key_length', 250) |
| 569 | + key_length = kwargs.pop('key_length', util.DEFAULT_CACHE_KEY_LENGTH) |
566 | 570 | if len(cache_key) + len(namespace) > int(key_length):
|
567 | 571 | if util.py3k:
|
568 | 572 | cache_key = cache_key.encode('utf-8')
|
|
0 commit comments