(key, ttl_sec, work_func)
return to_cache
Attempts to return value by key, otherwise caches and returns `work_func`
Attempts to return value by key, otherwise caches and returns `work_func`
Attempts to return value by key otherwise caches and returns work_func
def use_redis_cache(key, ttl_sec, work_func):
    """Attempts to return value by key, otherwise caches and returns `work_func`"""
    redis = redis_connection.get_redis()
    cached_value = get_pickled_key(redis, key)
    if cached_value:
        return cached_value
    to_cache = work_func()
    pickle_and_set(redis, key, to_cache, ttl_sec)
    return to_cache
def use_redis_cache ( key , ttl_sec , work_func ) : redis = redis_connection . get_redis ( ) cached_value = get_pickled_key ( redis , key ) if cached_value : return cached_value to_cache = work_func ( ) pickle_and_set ( redis , key , to_cache , ttl_sec ) return to_cache