Metadata-Version: 2.4
Name: kasper-cache
Version: 0.1.0
Summary: Pluggable cache adapter - one interface, swappable backends (in-memory, Redis).
Author-email: Kunta Mallik Raj <kuntamallikraj@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/KuntaMallikRaj
Keywords: cache,redis,adapter,backend,memoize
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: redis
Requires-Dist: redis>=4.2; extra == "redis"
Dynamic: license-file

# kasper-cache

One cache interface, swappable backends. Switch from in-memory to Redis by changing a URL, not your code.

```bash
pip install kasper-cache          # in-memory
pip install "kasper-cache[redis]" # + Redis backend
```

```python
from kasper_cache import Cache

cache = Cache.from_url("memory://")        # or "redis://localhost:6379/0"

cache.set("user:1", {"name": "Mallik"}, ttl=60)
cache.get("user:1")                        # -> {"name": "Mallik"}
cache.get_or_set("user:1", lambda: load(1), ttl=60)

@cache.memoize(ttl=30)
def expensive(x):
    ...
```

## Why
- **One interface** (`get`/`set`/`delete`/`get_or_set`/`memoize`) over many backends.
- `get_or_set` guards against the thundering-herd on a cache miss.
- In-memory is per-process and fast; Redis is shared and survives restarts.

MIT licensed.
