caches: improve logging

This commit is contained in:
RhodeCode Admin 2024-10-23 11:31:17 +02:00
parent c712ce33c0
commit f096d65f31

View file

@ -69,19 +69,17 @@ class RhodeCodeCacheRegion(CacheRegion):
def get_or_create_for_user_func(func_key_generator, user_func, *arg, **kw):
if not condition:
log.debug('Calling un-cached method:%s', user_func.__name__)
log.debug('Calling un-cached method:`%s`', user_func.__name__)
start = time.time()
result = user_func(*arg, **kw)
total = time.time() - start
log.debug('un-cached method:%s took %.4fs', user_func.__name__, total)
log.debug('Call for un-cached method:`%s` took %.4fs', user_func.__name__, total)
return result
key = func_key_generator(*arg, **kw)
timeout = expiration_time() if expiration_time_is_callable else expiration_time
log.debug('Calling cached (timeout=%s) method:`%s`', timeout, user_func.__name__)
timeout = expiration_time() if expiration_time_is_callable \
else expiration_time
log.debug('Calling cached method:`%s`', user_func.__name__)
return self.get_or_create(key, user_func, timeout, should_cache_fn, (arg, kw))
def cache_decorator(user_func):