Registry / database / theine

theine

JSON →
library2.0.0pypypi✓ verified 85d ago

Theine is a high performance in-memory cache library for Python, supporting TTL, LRU, LFU, and clock-based eviction policies. Current version 2.0.0 (release 2025 Q1) requires Python >=3.9. It offers optimized caching for applications needing low latency and high throughput.

pip install theine
INSTALL
IMPORT
SIG · THEINE
T
theine
databasepythonv2.0.0
Install
2.1s avg
Import
222ms
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.234s · 34.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.210s · 42MB
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cache
from theine import Cache

Create a simple key-value cache and perform get/set operations.

from theine import Cache cache = Cache('key-value') cache.set('name', 'Theine') print(cache.get('name')) # 'Theine'
Debug
Known issues
breakingIn v2.0.0, the import path changed from `theine.Theine` to `theine.Cache` and the constructor signature changed. Code using the old import will raise ImportError.
fix
Use `from theine import Cache` and create cache with `Cache('key-value')` instead of `Theine()`.
affects: >=2.0.0
deprecatedThe `TTLCache` and `LRUCache` subclasses are deprecated in v2.0.0. Use the unified `Cache` class with the appropriate eviction policy.
fix
Replace `TTLCache()` with `Cache('ttl')` and `LRUCache()` with `Cache('lru')`.
affects: 2.0.0
gotcha`Cache` policy argument is case-sensitive and must be one of the supported policies: 'key-value', 'ttl', 'lru', 'lfu', 'clock'. Typos like 'LRU' or 'lru ' (with space) will raise ValueError.
fix
Ensure the policy string exactly matches the documented options (lowercase, no spaces).
affects: >=2.0.0
Errors
Common errors & fixes
ImportError: cannot import name 'Theine' from 'theine'
Breaking change in v2.0.0: the main class was renamed from `Theine` to `Cache`.
fix
Change import to `from theine import Cache` and update instantiation to `Cache('key-value')`.
ValueError: 'lru' is not a valid Cache policy
Providing an unsupported or misspelled policy string (e.g., 'LRU' with uppercase).
fix
Use exactly the policy names: 'key-value', 'ttl', 'lru', 'lfu', or 'clock'. Ensure lowercase and correct spelling.
Upgrade
Version history
2.0.0latest on PyPI · released Aug 17, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
22
Meta
2
OpenAI (training)
1
Resources
theine — pip install theine · libregistry