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.
18 lines
400 B
18 lines
400 B
import json
|
|
import redis
|
|
|
|
from typing import Union, Set
|
|
|
|
from apps.utils import get_redis_client
|
|
|
|
|
|
def get_object_from_cache(cache_key: str, /, *, redis_instance: redis.StrictRedis = None) -> Union[Set[int], list]:
|
|
if not redis_instance:
|
|
redis_instance = get_redis_client()
|
|
|
|
value = redis_instance.get(cache_key)
|
|
if not value:
|
|
return []
|
|
|
|
return set(json.loads(value))
|