parameters: (key, ttl_sec, work_func)
return_statement: return to_cache
docstring: Attempts to return value by key, otherwise caches and returns `work_func`
docstring_summary: Attempts to return value by key, otherwise caches and returns `work_func`
docstring_tokens: Attempts to return value by key otherwise caches and returns work_func
function: 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
function_tokens: 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