Muffin-Redis -- Redis support for Muffin framework.
Contents
- python >= 3.9
Muffin-Redis should be installed using pip:
pip install muffin-redis
Optionally you may install the plugin with redislite:
$ pip install muffin-redis[redislite]
Setup the plugin and connect it into your app:
from muffin import Application
from muffin_redis import Plugin as Redis
# Create Muffin Application
app = Application('example')
# Initialize the plugin
# As alternative: redis = Redis(app, **options)
redis = Redis(address='redis://localhost')
redis.setup(app)
That's it now you are able to use the plugin inside your views:
@app.route('/some_url', methods=['POST'])
async def some_method(request):
"""Work with redis."""
value = await redis.get('key')
if value is None:
value = ... # Do some work
await redis.set('key', value, expire=60)
return value
For Asyncio the muffin-redis
uses aioredis library. So check the
library's docs for futher reference.
Name | Default value | Description |
url | "redis://localhost" |
Redis connection URL |
db | None |
Number of the Redis DB |
password | None |
Connection password |
encoding | "utf-8" |
Connection encoding |
poolsize | 10 |
Connections pool size (set 0 to disable pooling) |
decode_responses | True |
Decode binary responses |
jsonify | False |
Use json to store/read objects with get/set |
blocking | True |
Wait for an available connection |
timeout | 20 |
Timeout to get a connection |
redislite | False |
Use redislite instead of redis |
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-redis/issues
Development of Muffin-Redis happens at: https://github.com/klen/muffin-redis
- klen (Kirill Klenov)
Licensed under a MIT license.