fix iter.next ?
This commit is contained in:
parent
16eb3e3448
commit
41e92e277e
1 changed files with 4 additions and 2 deletions
|
@ -82,7 +82,8 @@ class LRUCache(collections.MutableMapping):
|
||||||
|
|
||||||
def first(self):
|
def first(self):
|
||||||
if len(self._keys_to_last_time) > 0:
|
if len(self._keys_to_last_time) > 0:
|
||||||
return iter(self._keys_to_last_time).next()
|
for key in self._keys_to_last_time:
|
||||||
|
return key
|
||||||
|
|
||||||
def sweep(self):
|
def sweep(self):
|
||||||
# O(n - m)
|
# O(n - m)
|
||||||
|
@ -91,7 +92,8 @@ class LRUCache(collections.MutableMapping):
|
||||||
while c < SWEEP_MAX_ITEMS:
|
while c < SWEEP_MAX_ITEMS:
|
||||||
if len(self._keys_to_last_time) == 0:
|
if len(self._keys_to_last_time) == 0:
|
||||||
break
|
break
|
||||||
key = iter(self._keys_to_last_time).next()
|
for key in self._keys_to_last_time:
|
||||||
|
break
|
||||||
last_t = self._keys_to_last_time[key]
|
last_t = self._keys_to_last_time[key]
|
||||||
if now - last_t <= self.timeout:
|
if now - last_t <= self.timeout:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Add table
Reference in a new issue