{"id":24707,"library":"theine","title":"Theine - High performance in-memory cache","description":"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.","status":"active","version":"2.0.0","language":"python","source_language":"en","source_url":"https://github.com/michaelkryukov/theine","tags":["cache","performance","memory"],"install":[{"cmd":"pip install theine","lang":"bash","label":"Standard install"}],"dependencies":[],"imports":[{"note":null,"wrong":null,"symbol":"Cache","correct":"from theine import Cache"}],"quickstart":{"code":"from theine import Cache\n\ncache = Cache('key-value')\ncache.set('name', 'Theine')\nprint(cache.get('name'))  # 'Theine'","lang":"python","description":"Create a simple key-value cache and perform get/set operations."},"warnings":[{"fix":"Use `from theine import Cache` and create cache with `Cache('key-value')` instead of `Theine()`.","message":"In 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.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace `TTLCache()` with `Cache('ttl')` and `LRUCache()` with `Cache('lru')`.","message":"The `TTLCache` and `LRUCache` subclasses are deprecated in v2.0.0. Use the unified `Cache` class with the appropriate eviction policy.","severity":"deprecated","affected_versions":"2.0.0"},{"fix":"Ensure the policy string exactly matches the documented options (lowercase, no spaces).","message":"`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.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change import to `from theine import Cache` and update instantiation to `Cache('key-value')`.","cause":"Breaking change in v2.0.0: the main class was renamed from `Theine` to `Cache`.","error":"ImportError: cannot import name 'Theine' from 'theine'"},{"fix":"Use exactly the policy names: 'key-value', 'ttl', 'lru', 'lfu', or 'clock'. Ensure lowercase and correct spelling.","cause":"Providing an unsupported or misspelled policy string (e.g., 'LRU' with uppercase).","error":"ValueError: 'lru' is not a valid Cache policy"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}