##// END OF EJS Templates
lrucachedict: implement clear()
Siddharth Agarwal -
r19710:887ffa22 default
parent child Browse files
Show More
@@ -242,6 +242,10 b' class lrucachedict(object):'
242 def __contains__(self, key):
242 def __contains__(self, key):
243 return key in self._cache
243 return key in self._cache
244
244
245 def clear(self):
246 self._cache.clear()
247 self._order = deque()
248
245 def lrucachefunc(func):
249 def lrucachefunc(func):
246 '''cache most recent results of function calls'''
250 '''cache most recent results of function calls'''
247 cache = {}
251 cache = {}
@@ -31,5 +31,8 b' def test_lrucachedict():'
31 d['f'] = 'vf'
31 d['f'] = 'vf'
32 printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
32 printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
33
33
34 d.clear()
35 printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
36
34 if __name__ == '__main__':
37 if __name__ == '__main__':
35 test_lrucachedict()
38 test_lrucachedict()
@@ -24,3 +24,8 b" d['d']: vd"
24 'e' in d: False
24 'e' in d: False
25 'f' in d: True
25 'f' in d: True
26 d['f']: vf
26 d['f']: vf
27 'b' in d: False
28 'c' in d: False
29 'd' in d: False
30 'e' in d: False
31 'f' in d: False
General Comments 0
You need to be logged in to leave comments. Login now