Metadata-Version: 2.4
Name: flowmaticcache
Version: 1.0.1
Summary: A small cache abstraction layer for Python, supporting Redis, Valkey, Memcached, FlowmaticDB and in-process memory.
Author: Flowmatic, UniForceMusic
License: MIT
Project-URL: Homepage, https://github.com/Flowmatic-AI/python-flowmaticcache
Project-URL: Repository, https://github.com/Flowmatic-AI/python-flowmaticcache
Project-URL: Issues, https://github.com/Flowmatic-AI/python-flowmaticcache/issues
Keywords: cache,abstraction,redis,valkey,memcached,memory
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Provides-Extra: redis
Requires-Dist: redis>=5.0; extra == "redis"
Provides-Extra: valkey
Requires-Dist: valkey>=6.0; extra == "valkey"
Provides-Extra: memcached
Requires-Dist: pymemcache>=4.0; extra == "memcached"
Provides-Extra: flowmaticdb
Requires-Dist: flowmaticdb>=4.0.0; extra == "flowmaticdb"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"
Requires-Dist: redis>=5.0; extra == "dev"
Requires-Dist: valkey>=6.0; extra == "dev"
Requires-Dist: pymemcache>=4.0; extra == "dev"
Requires-Dist: flowmaticdb>=4.0.0; extra == "dev"
Provides-Extra: all
Requires-Dist: redis>=5.0; extra == "all"
Requires-Dist: valkey>=6.0; extra == "all"
Requires-Dist: pymemcache>=4.0; extra == "all"
Requires-Dist: flowmaticdb>=4.0.0; extra == "all"

# python-flowmaticcache

A small cache abstraction for Python, with pluggable backends: Redis, Valkey,
Memcached, [flowmaticdb](https://github.com/Flowmatic-AI/python-flowmaticdb)
and an in-process shared-memory store.

## Install

```bash
pip install flowmaticcache                 # shared_memory works out of the box
pip install "flowmaticcache[redis]"        # Redis
pip install "flowmaticcache[valkey]"       # Valkey
pip install "flowmaticcache[memcached]"    # Memcached
pip install "flowmaticcache[flowmaticdb]"  # flowmaticdb-backed cache table
pip install "flowmaticcache[all]"          # every backend
pip install "flowmaticcache[dev]"          # pytest, mypy, ruff + all backends
```

## Usage

```python
from flowmaticcache import Cache

cache = Cache.shared_memory()
# cache = Cache.connect_redis(host="localhost", port=6379)
# cache = Cache.connect_valkey(host="localhost", port=6380)
# cache = Cache.connect_memcached(host="localhost", port=11211)
# cache = Cache.connect_flowmaticdb(db, table="cache")

cache.set("key", {"any": "picklable value"}, ttl=60)  # ttl in seconds, optional
cache.get("key")
cache.exists("key")
cache.delete("key")
cache.clear()

cache.add("key", "value", ttl=60)          # only sets if not already present, returns bool
cache.pull("key", default=None)            # get then delete
cache.remember("key", lambda: expensive(), ttl=60)  # get, or compute + store if missing/expired
```

## Testing

Redis, Valkey and Memcached tests run against local containers:

```bash
docker compose up -d
pip install -e ".[dev]"
pytest
```

Database-backed tests use `flowmaticdb`'s in-memory SQLite adapter, so no
external service is required for those.

## Publishing

```bash
./build-and-publish.sh
```

Reads `PYPI_API_KEY` from `.env` (see `.env.example`), builds the package and
uploads it to PyPI after confirmation.
