Skip to content

Commit

Permalink
refactor: simplified cache file as import is working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienHdz committed Oct 17, 2023
1 parent 1b18005 commit 1260b8a
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions backend/avatar_assistant_api/api/cache/cache.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
import importlib

from api.app_settings import AppSettings


def default_function(*args, **options):
def decorator(fn):
return fn

return decorator


caching_module = None
is_cache_enabled = False
ROUTE_CACHING = None
from cashews import cache, Cache as CacheConfigurator # noqa: F401


def initialize_caching(AppSettings):
Expand All @@ -27,15 +14,6 @@ def initialize_caching(AppSettings):
return cache_instance


try:
caching_module = importlib.import_module("cashews").cache
CacheConfigurator = importlib.import_module("cashews").Cache
is_cache_enabled = True

except ImportError:
caching_module = default_function

else:
caching_module = initialize_caching(AppSettings())

is_cache_enabled = True
caching_module = initialize_caching(AppSettings())
ROUTE_CACHING = caching_module

0 comments on commit 1260b8a

Please sign in to comment.