sanic redis extend
Project description
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()
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sanic_redis_extend-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sanic_redis_extend-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.4rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
981d6f30eb8d2ee7e6bbf5893bb95ea675456a3a9d7fe3b51bbeb97b14bde1ea
|
|
| MD5 |
e1af0e9e917d9d4d7b95206a83a54672
|
|
| BLAKE2b-256 |
8829ac1b04ba7ddfb209af9a68ab7020128312539b00c62b5582388ba5225b3a
|