Fix negative pop_count

This commit is contained in:
Ethan Dalool 2017-04-01 00:32:13 -07:00
parent 729f10b3a0
commit 9794773509

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)