Show More
@@ -275,11 +275,7 b' celery.task_always_eager = false' | |||||
275 | beaker.cache.data_dir = %(here)s/data/cache/data |
|
275 | beaker.cache.data_dir = %(here)s/data/cache/data | |
276 | beaker.cache.lock_dir = %(here)s/data/cache/lock |
|
276 | beaker.cache.lock_dir = %(here)s/data/cache/lock | |
277 |
|
277 | |||
278 |
beaker.cache.regions = |
|
278 | beaker.cache.regions = long_term,long_term_file | |
279 |
|
||||
280 | beaker.cache.short_term.type = memory |
|
|||
281 | beaker.cache.short_term.expire = 60 |
|
|||
282 | beaker.cache.short_term.key_length = 256 |
|
|||
283 |
|
279 | |||
284 | beaker.cache.long_term.type = memory |
|
280 | beaker.cache.long_term.type = memory | |
285 | beaker.cache.long_term.expire = 36000 |
|
281 | beaker.cache.long_term.expire = 36000 |
@@ -381,11 +381,7 b' celery.task_always_eager = false' | |||||
381 | beaker.cache.data_dir = %(here)s/data/cache/data |
|
381 | beaker.cache.data_dir = %(here)s/data/cache/data | |
382 | beaker.cache.lock_dir = %(here)s/data/cache/lock |
|
382 | beaker.cache.lock_dir = %(here)s/data/cache/lock | |
383 |
|
383 | |||
384 |
beaker.cache.regions = |
|
384 | beaker.cache.regions = long_term,long_term_file | |
385 |
|
||||
386 | beaker.cache.short_term.type = memory |
|
|||
387 | beaker.cache.short_term.expire = 60 |
|
|||
388 | beaker.cache.short_term.key_length = 256 |
|
|||
389 |
|
385 | |||
390 | beaker.cache.long_term.type = memory |
|
386 | beaker.cache.long_term.type = memory | |
391 | beaker.cache.long_term.expire = 36000 |
|
387 | beaker.cache.long_term.expire = 36000 |
@@ -602,32 +602,3 b' def check_git_version():' | |||||
602 | settings.GIT_EXECUTABLE_PATH, output) |
|
602 | settings.GIT_EXECUTABLE_PATH, output) | |
603 |
|
603 | |||
604 | return ver |
|
604 | return ver | |
605 |
|
||||
606 |
|
||||
607 | #=============================================================================== |
|
|||
608 | # CACHE RELATED METHODS |
|
|||
609 | #=============================================================================== |
|
|||
610 |
|
||||
611 | def conditional_cache(region, prefix, condition, func): |
|
|||
612 | """ |
|
|||
613 | Conditional caching function use like:: |
|
|||
614 | def func(arg): |
|
|||
615 | #heavy computation function |
|
|||
616 | return data |
|
|||
617 |
|
||||
618 | # depending from condition the compute is wrapped in cache or not |
|
|||
619 | compute = conditional_cache('short_term', 'cache_desc', condition=True, func=func) |
|
|||
620 | return compute(arg) |
|
|||
621 |
|
||||
622 | :param region: name of cache region |
|
|||
623 | :param prefix: cache region prefix |
|
|||
624 | :param condition: condition for cache to be triggered, and return data cached |
|
|||
625 | :param func: heavy function to compute |
|
|||
626 | """ |
|
|||
627 | wrapped = func |
|
|||
628 | if condition: |
|
|||
629 | log.debug('conditional_cache: True, wrapping call of ' |
|
|||
630 | 'func: %s into %s region cache' % (region, func)) |
|
|||
631 | wrapped = beaker.cache._cache_decorate((prefix,), None, None, region)(func) |
|
|||
632 |
|
||||
633 | return wrapped |
|
General Comments 0
You need to be logged in to leave comments.
Login now