pre-commit changes

This commit is contained in:
2024-12-08 12:17:19 +03:00
parent 2852ce1f96
commit 87e9029b09
15 changed files with 400 additions and 293 deletions

13
App/cache/wrapper.py vendored
View File

@@ -1,15 +1,18 @@
from functools import wraps
from . import RedisCache
def fetch_from_cache(cache_name: str, cache_config: dict):
cache_conn = RedisCache(cache_config['redis'])
ttl = cache_config['ttl']
cache_conn = RedisCache(cache_config["redis"])
ttl = cache_config["ttl"]
"""
It checks if a cached value exists for a given cache_name.
If a cached value exists, it returns the cached value.
If no cached value exists, it calls the original function f with the provided arguments, caches the result, and then returns the result.
"""
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
@@ -19,7 +22,9 @@ def fetch_from_cache(cache_name: str, cache_config: dict):
return cached_value
response = f(*args, **kwargs)
print("response=", response)
cache_conn.set_value(cache_name,response,ttl)
cache_conn.set_value(cache_name, response, ttl)
return response
return wrapper
return decorator
return decorator