Registry / database / cachettl

cachettl

JSON →
library1.0.4pypypi✓ verified 85d ago

cachettl is an elegant LRU TTL cache decorator for Python, supporting both synchronous and asyncio functions. Version 1.0.4 (latest) requires Python >=3.7. Provides cache_info(), cache_clear(), and a remainingttl property. Development appears stable with infrequent releases.

pip install cachettl
INSTALL
IMPORT
SIG · CACHETTL
C
cachettl
databasepythonv1.0.4
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.4 · 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.000s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

cachettl
from cachettl import cachettl
The decorator is named cachettl (lowercase).

Basic usage of cachettl decorator with maxsize and ttl.

from cachettl import cachettl import time @cachettl(maxsize=128, ttl=60) def expensive_function(n): return n * n print(expensive_function(5)) # Computes and caches print(expensive_function(5)) # Returns cached result print(expensive_function.cache_info()) # e.g., hits=1, misses=1 print(expensive_function.remainingttl()) # seconds left time.sleep(61) print(expensive_function(5)) # Recomputes after TTL expiry
Debug
Known issues
gotchaThe decorator name is cachettl (all lowercase), not cache_ttl or CacheTTL. Importing from cachettl import cachettl is required.
fix
Use 'from cachettl import cachettl' and decorate with @cachettl(...).
affects: all
gotchaThe decorator does not support keyword-only arguments like 'cache' or 'timeout'. Only positional parameters: maxsize, ttl, and maxage.
fix
Use @cachettl(maxsize=128, ttl=60) only. Do not pass other unexpected kwargs.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cachettl'
Package not installed or installed under a different name.
fix
Run 'pip install cachettl' to install the package.
TypeError: __init__() got an unexpected keyword argument 'timeout'
Using a non-existent keyword argument 'timeout' instead of 'ttl'.
fix
Replace 'timeout' with 'ttl' in the decorator call.
Upgrade
Version history
1.0.4latest on PyPI · released Jul 6, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cachettl — pip install cachettl · libregistry