Mercurial > kallithea
changeset 8346:f787c028ffc0
utils: drop conditional_cache - an unused beaker cache
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 20 Oct 2019 22:03:57 +0200 |
parents | f6be760c786c |
children | cd3f326d0ff1 |
files | development.ini kallithea/lib/paster_commands/template.ini.mako kallithea/lib/utils.py |
diffstat | 3 files changed, 2 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Sun Apr 12 02:43:56 2020 +0200 +++ b/development.ini Sun Oct 20 22:03:57 2019 +0200 @@ -275,11 +275,7 @@ beaker.cache.data_dir = %(here)s/data/cache/data beaker.cache.lock_dir = %(here)s/data/cache/lock -beaker.cache.regions = short_term,long_term,long_term_file - -beaker.cache.short_term.type = memory -beaker.cache.short_term.expire = 60 -beaker.cache.short_term.key_length = 256 +beaker.cache.regions = long_term,long_term_file beaker.cache.long_term.type = memory beaker.cache.long_term.expire = 36000
--- a/kallithea/lib/paster_commands/template.ini.mako Sun Apr 12 02:43:56 2020 +0200 +++ b/kallithea/lib/paster_commands/template.ini.mako Sun Oct 20 22:03:57 2019 +0200 @@ -381,11 +381,7 @@ beaker.cache.data_dir = %(here)s/data/cache/data beaker.cache.lock_dir = %(here)s/data/cache/lock -beaker.cache.regions = short_term,long_term,long_term_file - -beaker.cache.short_term.type = memory -beaker.cache.short_term.expire = 60 -beaker.cache.short_term.key_length = 256 +beaker.cache.regions = long_term,long_term_file beaker.cache.long_term.type = memory beaker.cache.long_term.expire = 36000
--- a/kallithea/lib/utils.py Sun Apr 12 02:43:56 2020 +0200 +++ b/kallithea/lib/utils.py Sun Oct 20 22:03:57 2019 +0200 @@ -602,32 +602,3 @@ settings.GIT_EXECUTABLE_PATH, output) return ver - - -#=============================================================================== -# CACHE RELATED METHODS -#=============================================================================== - -def conditional_cache(region, prefix, condition, func): - """ - Conditional caching function use like:: - def func(arg): - #heavy computation function - return data - - # depending from condition the compute is wrapped in cache or not - compute = conditional_cache('short_term', 'cache_desc', condition=True, func=func) - return compute(arg) - - :param region: name of cache region - :param prefix: cache region prefix - :param condition: condition for cache to be triggered, and return data cached - :param func: heavy function to compute - """ - wrapped = func - if condition: - log.debug('conditional_cache: True, wrapping call of ' - 'func: %s into %s region cache' % (region, func)) - wrapped = beaker.cache._cache_decorate((prefix,), None, None, region)(func) - - return wrapped