Open this example in the interactive library
Source code
from collections import OrderedDict
cache = OrderedDict(a=1, b=2)
cache.move_to_end('a')
print(cache.popitem(last=False))Sample output
('b', 2)
Use an ordered eviction cache. A self-contained example using the Python standard library.
Open this example in the interactive library
from collections import OrderedDict
cache = OrderedDict(a=1, b=2)
cache.move_to_end('a')
print(cache.popitem(last=False))('b', 2)