dd-cache
Backend-swappable caching layer for the dd-* ecosystem.
Install
pip install -e . # core (memory + disk)
pip install -e ".[redis]" # add Redis support
pip install -e ".[dev]" # + pytest
Quick start
from dd_cache import InMemoryCache, DiskCache
# In-process, TTL-aware
with InMemoryCache() as cache:
cache.set("key", {"data": 42}, ttl=60)
value = cache.get("key")
# Persistent SQLite
with DiskCache(".cache/myapp.db") as cache:
result = cache.get_or_set("expensive_key", lambda: run_expensive_query())
Adapters
| Class | Backend | Persistence | TTL | Extra deps |
|---|---|---|---|---|
InMemoryCache |
dict | process | lazy | none |
DiskCache |
SQLite | file | lazy | none |
RedisCache |
Redis | server | native | redis |
API
cache.get(key) # → Any | None
cache.set(key, value, ttl=None) # ttl in seconds
cache.delete(key) # → bool
cache.exists(key) # → bool
cache.clear()
cache.stats() # → CacheStats
cache.get_or_set(key, fn, ttl=None)
See docs/DESIGN.md for architecture details.
Metadata
Release files for dd-cache 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dd_cache-0.1.0.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dd_cache-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.3 kB
Release files / dd_cache-0.1.0.tar.gz
| Download URL | dd_cache-0.1.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91691330dee2b082ebe95fe68aa0d019c9a218d47d9e7c0fe02204956da77da2
|
|
BLAKE2b-256 checksum How to use checksums |
aec5881ceea06b2efd2e421de4a7988e822d815bd826bde810e4968e1c13484d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Release files / dd_cache-0.1.0-py3-none-any.whl
| Download URL | dd_cache-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ca745dbacc183662c1a2824272384beade70ffaaa3a5f5c4f792497f87f64db
|
|
BLAKE2b-256 checksum How to use checksums |
54021bf53a4c6d39443ace28ec74904888e3fd4517ef99603f2cbcf142ea77ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|