sanic-redis
Redis support for sanic.
Built on top of aioredis.
Installation
You can install this package as usual with pip:
pip install sanic-redis-extend
Config
For example:
redis://[[username]:[password]]@localhost:6379/0
rediss://[[username]:[password]]@localhost:6379/0
unix://[[username]:[password]]@/path/to/socket.sock?db=0
Example
from sanic import Sanic
from sanic.response import text
from sanic_redis_extend import SanicRedisExtend
app = Sanic(__name__)
app.config.update(
{
'REDIS': "redis://default:xxx@127.0.0.1:6379/1",
}
)
redis = SanicRedisExtend()
redis.init_app(app)
@app.route('/')
async def test3(request):
# request.app.ctx.{redis_name}, the {redis_name} == config_name.lower()
async with request.app.ctx.redis as r:
await r.set('key1', 'value1')
result = await r.get('key1')
return text(str(result))
if __name__ == '__main__':
app.run()
Metadata
Release files for sanic-redis-extend 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sanic_redis_extend-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / sanic_redis_extend-0.0.1-py3-none-any.whl
| Download URL | sanic_redis_extend-0.0.1-py3-none-any.whl |
|---|---|
| Size | 2.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
981d6f30eb8d2ee7e6bbf5893bb95ea675456a3a9d7fe3b51bbeb97b14bde1ea
|
|
BLAKE2b-256 checksum How to use checksums |
8829ac1b04ba7ddfb209af9a68ab7020128312539b00c62b5582388ba5225b3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.4rc1
|