1. Mikhail Korobov
  2. django-cache-utils


Mikhail Korobov  committed f157423

Fixed a bug: attempt to invalidate uncalled function no longer raise exception

  • Participants
  • Parent commits 96fa235
  • Branches default

Comments (0)

Files changed (3)

File cache_utils/decorators.py

View file
  • Ignore whitespace
         def invalidate(*args, **kwargs):
             ''' invalidates cache result for function called with passed arguments '''
+            if not hasattr(wrapper, '_full_name'):
+                return
             key = _cache_key(wrapper._full_name, 'function', args, kwargs)
             cache.delete(key, **backend_kwargs)

File cache_utils/tests.py

View file
  • Ignore whitespace
         self.assertEqual(foo.bar(1), 2)
+    def test_invalidate_nonexisting(self):
+        @cached(60)
+        def foo(x):
+            return 1
+        foo.invalidate(5) # this shouldn't raise exception
 class DecoratorTest(ClearMemcachedTest):

File setup.py

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