Muffin-Redis
Muffin-Redis — Redis support for the Muffin framework.
Features
- Built on
redis.asyncioclient. - Optional support for
fakeredisfor testing without a real Redis server. - JSON serialization support
- Automatic connection pool management (blocking or non-blocking).
- Simple
get()/set()with optionaljsonifyflag. - Lifecycle support:
startupandshutdownintegrate with Muffin app lifecycle.
Requirements
- Python >= 3.11
Installation
Install using pip:
pip install muffin-redis
Optionally with fakeredis:
pip install muffin-redis[fakeredis]
Usage
Setup the plugin and connect it into your app:
from muffin import Application
from muffin_redis import Plugin as Redis
app = Application('example')
# Initialize the plugin
redis = Redis(address='redis://localhost')
redis.setup(app)
You can now use Redis in your routes:
@app.route('/some_url', methods=['POST'])
async def some_method(request):
value = await redis.get('key')
if value is None:
value = ... # Do some work
await redis.set('key', value, expire=60)
return value
Under the hood, Muffin-Redis uses aioredis for asynchronous Redis support.
Configuration Options
| Name | Default | Description |
|---|---|---|
url |
"redis://localhost" |
Redis connection URL |
db |
None |
Redis DB index |
password |
None |
Redis password |
encoding |
"utf-8" |
Encoding used by the client |
poolsize |
10 |
Max pool size (set 0 to disable pooling) |
decode_responses |
True |
Whether to decode binary responses |
jsonify |
False |
Automatically encode/decode JSON with get/set |
blocking |
True |
Use a blocking connection pool |
timeout |
20 |
Timeout in seconds for getting a connection |
fake |
False |
Use fakeredis instead of a real Redis server |
Bug Tracker
Please report bugs or feature requests at: https://github.com/klen/muffin-redis/issues
Contributing
Development happens at: https://github.com/klen/muffin-redis
License
Licensed under the MIT license.
Credits
- Created by klen (Kirill Klenov)
Metadata
Release files for muffin-redis 4.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| muffin_redis-4.0.2.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| muffin_redis-4.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / muffin_redis-4.0.2.tar.gz
| Download URL | muffin_redis-4.0.2.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5163c3ed42ee45b1fb858315373237ff833b6f46f77e559c517596aea4c96c8
|
|
BLAKE2b-256 checksum How to use checksums |
a266396b25ec7f2fddab0b6df513af6cdacbb9489eaeca46f34768ed38f9ad23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / muffin_redis-4.0.2-py3-none-any.whl
| Download URL | muffin_redis-4.0.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87d0c82e9ab98875f0615cd8c517f51b240680b8cc7e447f48b5cebaa11298e2
|
|
BLAKE2b-256 checksum How to use checksums |
ce30161a74fb0ad7db6554a74dd223465509bb334bf46841a86eeaee08b787ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|