An efficient LRU cache written in Rust with Python bindings. Unlike other LRU cache implementations, this one behaves like a Python dictionary and does not wrap around a function.
Pre-built binary wheels are available for Linux, macOS, and Windows, with support for both x64 and ARM architectures.
pip install lrucache-rs
from lrucache_rs import LRUCache
cache: LRUCache[str, int] = LRUCache(maxsize=2)
cache['1'] = 1
cache['2'] = 2
cache['3'] = 3
assert cache.get('1') is None
assert cache.get('2') == 2
assert cache.get('3') == 3