semvec/pypi-packages huggingface dataset:
sanic-redis-extend 0.0.1
sanic redis extend
Requires Python: >=3.6
Keywords: sanic redis extend

sanic-redis
==============
Redis support for sanic.

Built on top of [aioredis](https://aioredis.readthedocs.io/en/latest/examples/).

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
------------
```python
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()
```