Redis support for Sanic framework
Project description
Redis support for Sanic framework
Features
Based on the aioredis library
Easy to use and configurate for your own projects
Installation
This package should be installed using pip:
pip install sanic-redis-extension
Example
from sanic import Sanic, response
from sanic_redis_ext import RedisExtension
app = Sanic(__name__)
# Configuration for Redis
app.config.update({
"REDIS_HOST": "127.0.0.1"
"REDIS_PORT": 6379
"REDIS_DATABASE": None
"REDIS_SSL": None
"REDIS_ENCODING": None
"REDIS_MIN_SIZE_POOL": 1
"REDIS_MAX_SIZE_POOL": 10
})
RedisExtension(app) # Connection pool is available as `app.redis` or `app.extensions['redis']`
@app.route("/")
async def handle(request):
with await request.app.redis as redis:
await redis.set('test-my-key', 'value')
val = await redis.get('test-my-key')
return response.text(val.decode('utf-8'))
License
The sanic-redis-extension is published under BSD license. For more details read LICENSE file.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for sanic_redis_extension-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00890b8fbf3db520c90cb69f9b38223262d60c5d80e928aa83ad0a255f351154 |
|
MD5 | d6f412aed9d53ae71c0551860083cf31 |
|
BLAKE2b-256 | 6538f1e56e558aa8d7f2fcb3ccf2dd04ef1e564670f895d8aa9c55fae8f71857 |