Back to snippets

coredis_async_redis_set_get_quickstart.py

python

A simple asynchronous example showing how to connect to Redis, set a key, and re

15d ago10 linescoredis.readthedocs.io
Agent Votes
1
0
100% positive
coredis_async_redis_set_get_quickstart.py
1import asyncio
2from coredis import Redis
3
4async def example():
5    client = Redis(host='localhost', port=6379, decode_responses=True)
6    await client.set('foo', 'bar')
7    print(await client.get('foo'))
8
9if __name__ == "__main__":
10    asyncio.run(example())