asyncio (PEP 3156) Redis support
Project description
asyncio (PEP 3156) Redis support
Documentation
Usage examples
Simple low-level interface:
import asyncio
import aioredis
loop = asyncio.get_event_loop()
@asyncio.coroutine
def go():
conn = yield from aioredis.create_connection(
('localhost', 6379), loop=loop)
yield from conn.execute('set', 'my-key', 'value')
val = yield from conn.execute('get', 'my-key')
print(val)
conn.close()
loop.run_until_complete(go())
# will print 'value'
Simple high-level interface:
import asyncio
import aioredis
loop = asyncio.get_event_loop()
@asyncio.coroutine
def go():
redis = yield from aioredis.create_redis(
('localhost', 6379), loop=loop)
yield from redis.set('my-key', 'value')
val = yield from redis.get('my-key')
print(val)
redis.close()
loop.run_until_complete(go())
# will print 'value'
Connections pool:
import asyncio
import aioredis
loop = asyncio.get_event_loop()
@asyncio.coroutine
def go():
pool = yield from aioredis.create_pool(
('localhost', 6379),
minsize=5, maxsize=10,
loop=loop)
with (yield from pool) as redis: # high-level redis API instance
yield from redis.set('my-key', 'value')
print((yield from redis.get('my-key')))
pool.clear() # closing all open connections
loop.run_until_complete(go())
Requirements
License
The aioredis is offered under MIT license.
Changes
0.1.0 (xxxx-xx-xx)
RedisConnection implemented
RedisPool implemented
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 Distribution
aioredis-0.0.2.tar.gz
(6.7 kB
view details)
Built Distribution
File details
Details for the file aioredis-0.0.2.tar.gz
.
File metadata
- Download URL: aioredis-0.0.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f712d7a367bb7d265bcb97b141e998f899c319665ee664862ad0d35ece50889 |
|
MD5 | 43fc56b6702373736774ed68ad65cc1d |
|
BLAKE2b-256 | 05b843ccc6a45a674522f2b97155b66cc107aa4fad5c80ec582bf778ac9e2b57 |
File details
Details for the file aioredis-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: aioredis-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 965c1e242ad271ef9acd7201cbc470947d52f48609437291798affd38231ef97 |
|
MD5 | 69e967564549169aa5597e6f059e749d |
|
BLAKE2b-256 | abffcba403b89b714900fc81cc699cb68b9dd0dd467a7be18320835154f0ff36 |