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() |
General Comments 0
You need to be logged in to leave comments.
Login now