Commit 5931dc72 by Őry Máté

common: add logging to method_cache

parent 93a898e7
from hashlib import sha224 from hashlib import sha224
from logging import getLogger
from time import time from time import time
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -9,6 +10,8 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -9,6 +10,8 @@ from django.utils.translation import ugettext_lazy as _
from model_utils.models import TimeStampedModel from model_utils.models import TimeStampedModel
logger = getLogger(__name__)
def activitycontextimpl(act): def activitycontextimpl(act):
try: try:
...@@ -105,6 +108,9 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa ...@@ -105,6 +108,9 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
# save to memcache and class attr # save to memcache and class attr
cache.set(key, result, memcached_seconds) cache.set(key, result, memcached_seconds)
setattr(instance, key, {'time': now, 'value': result}) setattr(instance, key, {'time': now, 'value': result})
logger.debug('Value of <%s>.%s(%s)=<%s> saved to cache.',
unicode(instance), method.__name__,
unicode(args), unicode(result))
return result return result
return x return x
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment