Skip to content

Instantly share code, notes, and snippets.

View prl900's full-sized avatar

Pablo Rozas Larraondo prl900

View GitHub Profile
@prl900
prl900 / cache_dict.py
Created April 13, 2022 10:56 — forked from davesteele/cache_dict.py
Python LRU Caching Dictionary - a dict with a limited number of entries, removing LRU elements as necessary
from collections import OrderedDict
# >>> import cache_dict
# >>> c = cache_dict.CacheDict(cache_len=2)
# >>> c[1] = 1
# >>> c[2] = 2
# >>> c[3] = 3
# >>> c
# CacheDict([(2, 2), (3, 3)])
# >>> c[2]