Redis support for Muffin framework.
Project description
Muffin-Redis – Redis support for Muffin framework.
Requirements
python >= 3.7
Installation
Muffin-Redis should be installed using pip:
pip install muffin-redis
To install fakeredis (for testing purposes):
pip install muffin-redis[fake]
Usage
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.
Configuration options
Name |
Default value |
Description |
address |
"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) |
jsonify |
False |
Use json to store/read objects with get/set |
fake |
False |
Use fakeredis. The option is convenient for testing |
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-redis/issues
Contributing
Development of Muffin-Redis happens at: https://github.com/klen/muffin-redis
Contributors
klen (Kirill Klenov)
License
Licensed under a 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
Hashes for muffin_redis-2.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d219eeecf82e166757738763a08d3a19cd251489fc65e8f5e0eb77bdda9d7a7 |
|
MD5 | 47140371286e7935aeaabb4f0024a3c9 |
|
BLAKE2b-256 | 523bd492dbbc179d24b95a43566f15719b3c029033651aa553a34b75821a7790 |