Redis connection building blocks for the fastfoundry ecosystem.
Project description
fastfoundry-redis
Redis connection building blocks for the fastfoundry ecosystem.
Part of the fastfoundry.* namespace (fastfoundry-settings, fastfoundry-postgres, …).
An async redis-py connection pool and client
lifecycle for a single Redis server, and a configuration model that plugs into
fastfoundry.settings.
Install
pip install fastfoundry-redis
# or
uv add fastfoundry-redis
Requires Python 3.12+.
Configuration
RedisCfg holds the connection parameters. It is designed to nest inside a
fastfoundry.settings.BaseAppSettings subclass, so the values load from the environment
with the rest of your service configuration, then get handed to redis_pool_ctx:
from fastfoundry.settings import BaseAppSettings
from fastfoundry.redis import RedisCfg
class Settings(BaseAppSettings):
redis: RedisCfg
settings = Settings()
With the FF_ prefix and __ nested delimiter that BaseAppSettings applies, the
fields are read from the environment as FF_REDIS__HOST, FF_REDIS__PORT,
FF_REDIS__DB, and so on. password is optional (omit it for a server without auth).
Connection pool & client lifecycle
Open redis_pool_ctx(settings.redis) once for the application lifetime — it builds the
connection pool, publishes it for ambient access (get_pool() and redis_cfg()), and
disconnects it on exit. For FastAPI, wire it into the lifespan:
from contextlib import asynccontextmanager
from collections.abc import AsyncGenerator
from fastapi import FastAPI
from fastfoundry.redis import redis_pool_ctx
from app.settings import settings
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:
async with redis_pool_ctx(settings.redis):
yield
app = FastAPI(lifespan=lifespan)
Acquire a client with redis_client; it draws a connection from the pool and returns it
on exit. Responses are decoded to str by default (decode_responses=True):
from fastfoundry.redis import redis_client
async with redis_client() as rc:
await rc.set("key", "value")
value = await rc.get("key")
Development
mise run install # uv sync --dev
mise run lint # ruff check
mise run typecheck # mypy --strict
mise run test # pytest
mise run build # uv build (sdist + wheel)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastfoundry_redis-1.0.0.tar.gz.
File metadata
- Download URL: fastfoundry_redis-1.0.0.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01427edf92d0862fb45de62a66f87ca03b1713c853f2d505a69b564701cc720c
|
|
| MD5 |
41a1aea05943bab3afd4838af741edeb
|
|
| BLAKE2b-256 |
f3fa582236fa2ce7d3dd63b590a0ad360685b763f238a4d1df0a028edadbf383
|
Provenance
The following attestation bundles were made for fastfoundry_redis-1.0.0.tar.gz:
Publisher:
release.yml on Drozdetskiy/fastfoundry-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastfoundry_redis-1.0.0.tar.gz -
Subject digest:
01427edf92d0862fb45de62a66f87ca03b1713c853f2d505a69b564701cc720c - Sigstore transparency entry: 1818492470
- Sigstore integration time:
-
Permalink:
Drozdetskiy/fastfoundry-redis@03f24fc7cdb8a2c4f19ca7d9d75b389a4480dc0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Drozdetskiy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@03f24fc7cdb8a2c4f19ca7d9d75b389a4480dc0b -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastfoundry_redis-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fastfoundry_redis-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e75252ac660d8543529960c829577781c5740029dca9c2ae0cd15fc13edb5bf4
|
|
| MD5 |
f1d52e6c6533ac76b3fb03715a1ae943
|
|
| BLAKE2b-256 |
03b61b59d1a2c241dfe10af5643dc95c14e031f80222cf979d62c432581b3f1c
|
Provenance
The following attestation bundles were made for fastfoundry_redis-1.0.0-py3-none-any.whl:
Publisher:
release.yml on Drozdetskiy/fastfoundry-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastfoundry_redis-1.0.0-py3-none-any.whl -
Subject digest:
e75252ac660d8543529960c829577781c5740029dca9c2ae0cd15fc13edb5bf4 - Sigstore transparency entry: 1818492486
- Sigstore integration time:
-
Permalink:
Drozdetskiy/fastfoundry-redis@03f24fc7cdb8a2c4f19ca7d9d75b389a4480dc0b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Drozdetskiy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@03f24fc7cdb8a2c4f19ca7d9d75b389a4480dc0b -
Trigger Event:
push
-
Statement type: