def memoize(*args, **kwargs): _cache_type = kwargs.pop('cache_type', 'simple') namespace = kwargs.pop('namespace', DEF_NS) cache_type = get_cache_type() if _cache_type == 'auto' else _cache_type config = merge([MEMOIZE_DEFAULTS, CACHE_CONFIGS[cache_type]]) if 'CACHE_TIMEOUT' in kwargs: config['CACHE_TIMEOUT'] = kwargs.pop('CACHE_TIMEOUT') if 'CACHE_THRESHOLD' in kwargs: config['CACHE_THRESHOLD'] = kwargs.pop('CACHE_THRESHOLD') cache = Cache(namespace=namespace, **config) return cache.memoize(*args, **kwargs)
def memoize(*args, **kwargs): cache_type = kwargs.pop('cache_type', 'simple') cache = Cache(**CACHE_CONFIGS[cache_type]) return cache.memoize(*args, **kwargs)