Merge branch 'main' into asyncio

This commit is contained in:
Andrew Brookins 2021-11-09 15:59:10 -08:00
commit ca6ae7d6e9
47 changed files with 3285 additions and 760 deletions

22
aredis_om/connections.py Normal file
View file

@ -0,0 +1,22 @@
import os
import aioredis
import dotenv
dotenv.load_dotenv()
URL = os.environ.get("REDIS_OM_URL", None)
def get_redis_connection(**kwargs) -> aioredis.Redis:
# If someone passed in a 'url' parameter, or specified a REDIS_OM_URL
# environment variable, we'll create the Redis client from the URL.
url = kwargs.pop("url", URL)
if url:
return aioredis.Redis.from_url(url, **kwargs)
# Decode from UTF-8 by default
if "decode_responses" not in kwargs:
kwargs["decode_responses"] = True
return aioredis.Redis(**kwargs)