Commits

Mikhail Korobov committed f157423

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

  • Participants
  • Parent commits 96fa235

Comments (0)

Files changed (3)

File cache_utils/decorators.py

 
         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

         Foo.bar.invalidate(1)
         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):
 
 #!/usr/bin/env python
 from distutils.core import setup
 
-version='0.6.1'
+version='0.6.2'
 
 setup(
     name='django-cache-utils',