mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
lrucachedict: implement clear()
This commit is contained in:
parent
6e9f30dc4d
commit
26051a2eee
@ -242,6 +242,10 @@ class lrucachedict(object):
|
||||
def __contains__(self, key):
|
||||
return key in self._cache
|
||||
|
||||
def clear(self):
|
||||
self._cache.clear()
|
||||
self._order = deque()
|
||||
|
||||
def lrucachefunc(func):
|
||||
'''cache most recent results of function calls'''
|
||||
cache = {}
|
||||
|
@ -31,5 +31,8 @@ def test_lrucachedict():
|
||||
d['f'] = 'vf'
|
||||
printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
|
||||
|
||||
d.clear()
|
||||
printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_lrucachedict()
|
||||
|
@ -24,3 +24,8 @@ d['d']: vd
|
||||
'e' in d: False
|
||||
'f' in d: True
|
||||
d['f']: vf
|
||||
'b' in d: False
|
||||
'c' in d: False
|
||||
'd' in d: False
|
||||
'e' in d: False
|
||||
'f' in d: False
|
||||
|
Loading…
Reference in New Issue
Block a user