Redis cache backend plugin for Spakky Framework
Project description
Spakky Redis
Redis cache backend plugin for Spakky Framework.
Installation
pip install spakky-redis
Features
- Shared cache backend:
RedisCache[T]stores values in Redis so multiple process instances can observe the same entries. - Core contract compatibility: Implements
spakky-cachesync and asyncICache[T]paths. - TTL semantics: Positive TTL values are translated into Redis millisecond expiry; missing and expired keys return
CacheMiss. - Loud failures: Redis connection/configuration failures and serialization failures are raised as Spakky cache errors.
- Scoped clear:
clearremoves keys under the configured prefix instead of flushing the Redis database.
Quick Start
from datetime import timedelta
from spakky.cache import CacheHit
from spakky.plugins.redis import RedisCache
cache = RedisCache[str]()
cache.set("profile:42", "Ada", ttl=timedelta(minutes=5))
result = cache.get("profile:42")
if isinstance(result, CacheHit):
print(result.value)
Configuration
RedisCacheConfig follows the standard Spakky @Configuration pattern and reads environment variables with the SPAKKY_REDIS__ prefix.
| Environment variable | Default |
|---|---|
SPAKKY_REDIS__HOST |
localhost |
SPAKKY_REDIS__PORT |
6379 |
SPAKKY_REDIS__DB |
0 |
SPAKKY_REDIS__USERNAME |
unset |
SPAKKY_REDIS__PASSWORD |
unset |
SPAKKY_REDIS__USE_SSL |
false |
SPAKKY_REDIS__KEY_PREFIX |
spakky:cache: |
SPAKKY_REDIS__SOCKET_TIMEOUT |
5.0 |
Async Usage
from spakky.cache import CacheHit
from spakky.plugins.redis import RedisCache
cache = RedisCache[int]()
await cache.set_async("answer", 42)
result = await cache.get_async("answer")
if isinstance(result, CacheHit):
assert result.value == 42
Contract Notes
RedisCache is a backend implementation of the spakky-cache application data cache contract. Business code should depend on ICache[T] and can switch between InMemoryCache and RedisCache without changing cache hit/miss handling.
Values are serialized with pickle and stored under SPAKKY_REDIS__KEY_PREFIX. clear() and clear_async() delete only keys under that prefix. Redis failures, unexpected response types, and serialization failures are raised as Spakky cache errors instead of being treated as cache misses.
This plugin does not add distributed locks, cache stampede protection, tag invalidation, write-through/write-behind policies, or metrics exporters.
License
MIT License
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 spakky_redis-6.3.1.tar.gz.
File metadata
- Download URL: spakky_redis-6.3.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d11c6d373e13dc70ea6ec53bbaa29e4e7ba1736041439a37a388127b6e03795
|
|
| MD5 |
95b3711574061e360a5496c7d50c4e4a
|
|
| BLAKE2b-256 |
b7fe474212cc4ec67f62b2bdd8047161c6338d902a320403618ebebdb64b0210
|
Provenance
The following attestation bundles were made for spakky_redis-6.3.1.tar.gz:
Publisher:
publish-package.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_redis-6.3.1.tar.gz -
Subject digest:
7d11c6d373e13dc70ea6ec53bbaa29e4e7ba1736041439a37a388127b6e03795 - Sigstore transparency entry: 1435894675
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spakky_redis-6.3.1-py3-none-any.whl.
File metadata
- Download URL: spakky_redis-6.3.1-py3-none-any.whl
- Upload date:
- Size: 7.5 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 |
6555c71bd89674d85146a997246925e7cca78f9c7ecfabfc49ccc2b6400d72d1
|
|
| MD5 |
a4cd8e97478e8d96d8138e5ff3771d0d
|
|
| BLAKE2b-256 |
991d481d5d9cb67e747497bd1a08019d6d1bd1972c93a468411eb1e7e89b03ac
|
Provenance
The following attestation bundles were made for spakky_redis-6.3.1-py3-none-any.whl:
Publisher:
publish-package.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_redis-6.3.1-py3-none-any.whl -
Subject digest:
6555c71bd89674d85146a997246925e7cca78f9c7ecfabfc49ccc2b6400d72d1 - Sigstore transparency entry: 1435894709
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@9b55f2f729fb6e6397bbf0d1ce584eaec72ffef8 -
Trigger Event:
workflow_dispatch
-
Statement type: