bpo-40651: Improve LRU recipe in the OrderedDict documentation (GH-#20139)
This commit is contained in:
parent
3a855b26ae
commit
bb8635cc3b
|
@ -1161,6 +1161,8 @@ variants of :func:`functools.lru_cache`::
|
|||
return value
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if key in self:
|
||||
self.move_to_end(key)
|
||||
super().__setitem__(key, value)
|
||||
if len(self) > self.maxsize:
|
||||
oldest = next(iter(self))
|
||||
|
|
Loading…
Reference in New Issue