def wrapper(*args, **kwargs): # full name is stored as attribute on first call if not hasattr(wrapper, '_full_name'): name, _args = _func_info(func, args) wrapper._full_name = name # try to get the value from cache key = get_key(wrapper._full_name, func_type, args, kwargs) value = cache.get(key, **backend_kwargs) # in case of cache miss recalculate the value and put it to the cache if value is None: value = func(*args, **kwargs) cache.set(key, value, timeout, **backend_kwargs) return value
def full_name(*args): # full name is stored as attribute on first call if not hasattr(wrapper, '_full_name'): name, _args = _func_info(func, args) wrapper._full_name = name
def assertFuncInfo(self, func, args_in, name, args_out): info = _func_info(func, args_in) self.assertEqual(info[0], name) self.assertEqual(info[1], args_out)
def _cache_func_name(self, args): # full name is stored as attribute on first call if not hasattr(self, '_full_name'): name, _args = _func_info(self.func, args) self._full_name = name