Skip to main content

python-flowmaticcache

A small cache abstraction for Python, with pluggable backends: Redis, Valkey, Memcached, flowmaticdb and an in-process shared-memory store.

Install

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

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:

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

./build-and-publish.sh

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

Release files for flowmaticcache 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flowmaticcache 1.0.1
File Size Uploaded
flowmaticcache-1.0.1.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flowmaticcache 1.0.1
File Interpreter ABI Platform
flowmaticcache-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / flowmaticcache-1.0.1.tar.gz

Download URL flowmaticcache-1.0.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7ec45e5a6387c2cc0d85b7f4bc2f465a30f5c1eff337df15aef24f0d15bc985c
BLAKE2b-256 checksum
How to use checksums
d82bf6b014848e98b5fba8f476427130ec347507ce89c02d513379392f137319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / flowmaticcache-1.0.1-py3-none-any.whl

Download URL flowmaticcache-1.0.1-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b18073fd1580ba1a57a4679334b3d80a04c6503bab2d3faa60a5c294dedb254
BLAKE2b-256 checksum
How to use checksums
c0a45a3c826d23d3676d4ded9e99e81735848d3394f2dc5dac707ec463d78ab1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page