Use cache.pop() instead of a separate membership test + del []
parent
27080698e7
commit
f53fcbce97
|
@ -75,8 +75,7 @@ def cached(max_entries=1000):
|
|||
defer.returnValue(ret)
|
||||
|
||||
def invalidate(key):
|
||||
if key in cache:
|
||||
del cache[key]
|
||||
cache.pop(key, None)
|
||||
|
||||
wrapped.invalidate = invalidate
|
||||
wrapped.prefill = prefill
|
||||
|
|
|
@ -66,6 +66,13 @@ class CacheDecoratorTestCase(unittest.TestCase):
|
|||
|
||||
self.assertEquals(callcount[0], 2)
|
||||
|
||||
def test_invalidate_missing(self):
|
||||
@cached()
|
||||
def func(self, key):
|
||||
return key
|
||||
|
||||
func.invalidate("what")
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_max_entries(self):
|
||||
callcount = [0]
|
||||
|
|
Loading…
Reference in New Issue