Fix negative pop_count

master
Ethan Dalool 2017-04-01 00:32:13 -07:00
parent 729f10b3a0
commit 9794773509
1 changed files with 1 additions and 0 deletions

View File

@ -38,6 +38,7 @@ class Cache:
pop_count = 0
else:
pop_count = len(self._dict) - self.maxlen
pop_count = max(0, pop_count)
keys = sorted(self._recency.keys(), key=self._recency.get)
for key in itertools.islice(keys, 0, pop_count):
self.remove(key)