Mikhail Korobov avatar Mikhail Korobov committed 4b3ea78

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

Comments (0)

Files changed (2)


         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
 #!/usr/bin/env python
 from distutils.core import setup
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.