Files
scwrypts/py/lib/redis/client.py
T

20 lines
478 B
Python
Raw Normal View History

2022-04-28 16:09:23 -06:00
from redis import StrictRedis
2023-01-11 17:09:59 -07:00
from py.lib.scwrypts import getenv
2022-04-28 16:09:23 -06:00
2023-02-21 18:44:27 -07:00
CLIENT = None
2022-04-28 16:09:23 -06:00
2023-02-21 18:44:27 -07:00
def get_client():
global CLIENT # pylint: disable=global-statement
if CLIENT is None:
print('getting redis client')
CLIENT = StrictRedis(
2022-04-28 16:09:23 -06:00
host = getenv('REDIS_HOST'),
port = getenv('REDIS_PORT'),
2022-08-02 19:08:33 -06:00
password = getenv('REDIS_AUTH', required=False),
2022-04-28 16:09:23 -06:00
decode_responses = True,
)
2023-02-21 18:44:27 -07:00
return CLIENT