Redis support for Muffin framework.
Project description
Muffin-Redis – Redis support for Muffin framework.
Requirements
python >= 3.9
Installation
Muffin-Redis should be installed using pip:
pip install muffin-redis
Optionally you may install the plugin with redislite:
$ pip install muffin-redis[redislite]
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 |
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 |
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
File details
Details for the file muffin_redis-3.8.0.tar.gz
.
File metadata
- Download URL: muffin_redis-3.8.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7264febbf1bc1bcfe604e26abccf8429f3686c2a1f4b6460a087c337114cfea1 |
|
MD5 | 56d38828dd476560ef82ec24f4e5e61e |
|
BLAKE2b-256 | e6d5ac1bcc1405cd2bbccb9181a38ddd757cee7de360db128de4ba9850bdd24b |
File details
Details for the file muffin_redis-3.8.0-py3-none-any.whl
.
File metadata
- Download URL: muffin_redis-3.8.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5214a5ab77234f05df0f2603ce42c82f35bed68e1afa10472bb87c2899cc03fa |
|
MD5 | 69922729a1fa9dd774655a982959432f |
|
BLAKE2b-256 | f8c7980cab663132f8ebe436ac193729ea226e6151d8eab439770b097a0af258 |