You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
452 B
21 lines
452 B
|
6 days ago
|
import redis
|
||
|
|
import json
|
||
|
|
from config import redis_config
|
||
|
|
|
||
|
|
redis_conn = redis.Redis(**redis_config, decode_responses=True)
|
||
|
|
|
||
|
|
|
||
|
|
def redis_get_key(key):
|
||
|
|
try:
|
||
|
|
val = redis_conn.get(key)
|
||
|
|
if val is not None:
|
||
|
|
return json.loads(val)
|
||
|
|
else:
|
||
|
|
print(f"key {key} not found")
|
||
|
|
except Exception as e:
|
||
|
|
print('redis_get_key', e)
|
||
|
|
|
||
|
|
|
||
|
|
def redis_set_key(key, value):
|
||
|
|
return redis_conn.set(key, value, ex=72000)
|