Theine is a high-performance, in-memory cache library for Python with support for TTL, LRU, LFU, and windowed TinyLFU eviction policies. Current version 2.1.0 requires Python >=3.10 and is actively maintained.
pip install theine-coreVerified import paths — ran on the pinned version, not inferred.
Basic LRU cache with TTL and a context manager example.
Use 'from theine import Cache' (not theine-core, not theine_core).
Use 'maxsize' instead of 'max_size'. Also, the 'ttl' parameter now expects seconds as an integer, not a timedelta.
Use external locking if you need concurrent writes, or consider a thread-safe cache like cachetools.
Set maxsize to a power of two (e.g., 1024, 2048) when using 'tinylfu' or 'windowed_tinylfu'.
No dependency data recorded yet.