1. grillermo
  2. django-cache-utils


Mikhail Korobov  committed 4b3ea78

'cached' decorator now works with standard django cache backends (without 'group' support)

  • Participants
  • Parent commits 0adb40c
  • Branches default

Comments (0)

Files changed (2)

File cache_utils/decorators.py

View file
  • Ignore whitespace
         constructing cache key.
+    backend_kwargs = {'group': group} if group else {}
     def _cached(func):
         # check if decorator is applied to function, method or classmethod
             key = '[cached]%s(%s)' % (func_name, get_args_string(key_args, kwargs))
             # try to get the value from cache
-            value = cache.get(key, group=group)
+            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, group=group)
+                cache.set(key, value, timeout, **backend_kwargs)
             return value
         return wrapper
     return _cached

File setup.py

View file
  • Ignore whitespace
 #!/usr/bin/env python
 from distutils.core import setup