Fix negative pop_count
This commit is contained in:
parent
729f10b3a0
commit
9794773509
1 changed files with 1 additions and 0 deletions
|
@ -38,6 +38,7 @@ class Cache:
|
||||||
pop_count = 0
|
pop_count = 0
|
||||||
else:
|
else:
|
||||||
pop_count = len(self._dict) - self.maxlen
|
pop_count = len(self._dict) - self.maxlen
|
||||||
|
pop_count = max(0, pop_count)
|
||||||
keys = sorted(self._recency.keys(), key=self._recency.get)
|
keys = sorted(self._recency.keys(), key=self._recency.get)
|
||||||
for key in itertools.islice(keys, 0, pop_count):
|
for key in itertools.islice(keys, 0, pop_count):
|
||||||
self.remove(key)
|
self.remove(key)
|
||||||
|
|
Loading…
Reference in a new issue