Skip to content

Instantly share code, notes, and snippets.

@guyroyse
Created June 25, 2020 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyroyse/0312095900c96ce07afaa334b10556a8 to your computer and use it in GitHub Desktop.
Save guyroyse/0312095900c96ce07afaa334b10556a8 to your computer and use it in GitHub Desktop.
import asyncio
import aioredis
async def main():
redis = await aioredis.create_redis('redis://:foobared@localhost:6379/0', encoding='utf-8')
await asyncio.gather(
add_to_stream(redis, 1, 'Possible vocalizations east of Makanda', 'Class B'),
add_to_stream(redis, 2, 'Sighting near the Columbia River', 'Class A'),
add_to_stream(redis, 3, 'Chased by a tall hairy creature', 'Class A'))
redis.close()
await redis.wait_closed()
def add_to_stream(redis, id, title, classification):
return redis.xadd('bigfoot:sightings:stream', {
'id': id, 'title': title, 'classification': classification })
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment