Metadata-Version: 2.3
Name: nyxa-cache
Version: 0.1.0
Summary: Cache helpers for Nyxa — memory default, optional Redis
Keywords: fastapi,cache,redis,nyxa
Author: Al-Amin Islam Nerob
Author-email: Al-Amin Islam Nerob <alamin@aincoder.com>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Dist: nyxa>=0.1.0
Requires-Dist: redis>=5.0 ; extra == 'redis'
Requires-Python: >=3.11
Project-URL: Homepage, https://nyxadev.com
Project-URL: Repository, https://github.com/NyxaDev/nyxa
Provides-Extra: redis
Description-Content-Type: text/markdown

# nyxa-cache — batteries-included cache for Nyxa

In-memory (default) and optional Redis cache for apps built with
[nyxa](https://pypi.org/project/nyxa/). Core `nyxa` does **not**
depend on Redis.

## At a glance

| What you need | Nyxa Cache |
| --- | --- |
| Read / write a key | `cache.get` / `cache.put` |
| Compute once, then cache | `cache.remember` / `cache.remember_async` |
| Remove one key / clear all | `cache.forget` / `cache.flush` |
| Shared Redis backend | `CACHE_STORE=redis` + `CACHE_REDIS_URL` / `REDIS_URL` |

## Install

```bash
uv add nyxa-cache
# optional Redis backend:
uv add 'nyxa-cache[redis]'
```

## Quick start

```python
from nyxa_cache import cache

cache.put("greeting", "hello", ttl=60)
assert cache.get("greeting") == "hello"

value = cache.remember("user:1", 120, lambda: {"id": 1})

# In async services:
user = await cache.remember_async(f"user:{item_id}", 60, lambda: load_user(item_id))
```

## Configuration

```bash
CACHE_STORE=memory          # default
# CACHE_STORE=redis
# CACHE_REDIS_URL=redis://localhost:6379/0
# REDIS_URL=...             # fallback when CACHE_REDIS_URL unset
```

## CLI

```bash
uv run nyxa cache clear
```
