Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/relrin/sanic-redis-extension
Redis support for Sanic framework
https://github.com/relrin/sanic-redis-extension
extension python redis sanic
Last synced: 30 days ago
JSON representation
Redis support for Sanic framework
- Host: GitHub
- URL: https://github.com/relrin/sanic-redis-extension
- Owner: Relrin
- License: bsd-3-clause
- Created: 2018-02-24T07:44:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T22:37:33.000Z (almost 2 years ago)
- Last Synced: 2024-10-01T06:44:50.212Z (about 1 month ago)
- Topics: extension, python, redis, sanic
- Language: Python
- Size: 8.79 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
sanic-redis-extension
#####################
Redis support for Sanic frameworkFeatures
========
- Based on the redis_ library
- Easy to use and configurate for your own projectsInstallation
============
This package should be installed using pip: ::pip install sanic-redis-extension
Example
=======
.. code-block:: pythonfrom sanic import Sanic, response
from sanic_redis_ext import RedisExtensionapp = Sanic(__name__)
# Configuration for Redis
app.config.update({
"REDIS_HOST": "127.0.0.1",
"REDIS_PORT": 6379,
"REDIS_DATABASE": 0,
"REDIS_MAX_CONNECTIONS": 15,
})
RedisExtension(app) # Connection pool is available as `app.ctx.redis` or `app.ctx.extensions['redis']`@app.route("/")
async def handle(request):
await request.app.ctx.redis.set('test-my-key', 'value')
val = await request.app.ctx.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... _links:
.. _redis: https://redis.readthedocs.io/
.. _LICENSE: https://github.com/Relrin/sanic-redis-extension/blob/master/LICENSE