Registry / database / disklru

disklru

JSON →
library2.0.4pypypi✓ verified 81d ago

A disk-based LRU (Least Recently Used) cache for Python that stores cached data on disk, providing persistent caching across sessions. Current version 2.0.4 supports Python >=3.8, with a simple decorator and function-based API. Release cadence is irregular, with updates as needed.

pip install disklru
INSTALL
IMPORT
SIG · DISKLRU
D
disklru
databasepythonv2.0.4
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.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 · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

DiskLRUCache
from disklru import DiskLRUCache
from disklru import DiskLRU

Create a disk-based LRU cache and use the decorator to cache function results.

from disklru import DiskLRU cache = DiskLRU(capacity=10, cache_dir='/tmp/my_cache') @cache.cache() def expensive_function(key): return f'result for {key}' print(expensive_function('a')) # cached
Debug
Known issues
breakingIn version 2.0.0, the API changed significantly. The old `discache` function is removed. Use `DiskLRU` class with `@cache.cache()` decorator instead of `@discache()`. Also, the `lru_cache` decorator was added.
fix
Replace `from disklru import discache` with `from disklru import DiskLRU` and use `cache = DiskLRU(...); @cache.cache()`
affects: <2.0.0 to >=2.0.0
gotchaThe cache directory persists between runs. If you change the function logic, you must manually clear the cache directory to invalidate stale entries.
fix
Delete the cache_dir or implement versioning in the cache key.
affects: all
gotchaPickle is used for serialization, so cached objects must be picklable. Custom objects may fail.
fix
Ensure all cached data can be serialized with pickle.
affects: all
Upgrade
Version history
2.0.4latest on PyPI · released Dec 12, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
disklru — pip install disklru · libregistry