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):
|
def __contains__(self, key):
|
||||||
return key in self._cache
|
return key in self._cache
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self._cache.clear()
|
||||||
|
self._order = deque()
|
||||||
|
|
||||||
def lrucachefunc(func):
|
def lrucachefunc(func):
|
||||||
'''cache most recent results of function calls'''
|
'''cache most recent results of function calls'''
|
||||||
cache = {}
|
cache = {}
|
||||||
|
@ -31,5 +31,8 @@ def test_lrucachedict():
|
|||||||
d['f'] = 'vf'
|
d['f'] = 'vf'
|
||||||
printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
|
printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
|
||||||
|
|
||||||
|
d.clear()
|
||||||
|
printifpresent(d, ['b', 'c', 'd', 'e', 'f'])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_lrucachedict()
|
test_lrucachedict()
|
||||||
|
@ -24,3 +24,8 @@ d['d']: vd
|
|||||||
'e' in d: False
|
'e' in d: False
|
||||||
'f' in d: True
|
'f' in d: True
|
||||||
d['f']: vf
|
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