asyncio-redisPython asyncio 的 Redis 客户端
asyncio-redis 是 Python asyncio 的 Redis 客户端 (PEP 3156)。这个 Redis 库是完全异步的,Reids 服务器非阻塞客户端,依赖于 asyncio,所以要求 Python 3.3. 或者 Python 3.4。
连接示例:
import asyncio import asyncio_redis @asyncio.coroutine def example(): # Create Redis connection connection = yield from asyncio_redis.Connection.create(host='localhost', port=6379) # Set a key yield from connection.set('my_key', 'my_value') # When finished, close the connection. connection.close() if __name__ == '__main__': loop = asyncio.get_event_loop() loop.run_until_complete(example())
评论