Можно ли сделать так, чтобы при вызове await Info.extract(user_id, Key.first_visit), использовались атрибуты класса Info, а не CacheManager?
class CacheManager:
cache = TTLCache(maxsize=100, ttl=600)
data = {}
@staticmethod
def _check(func):
async def wrapper(user_id: int, *args, **kwargs):
cache = CacheManager.cache
if user_id not in cache:
cache[user_id] = CacheManager.data
return await func(user_id, *args, **kwargs)
return wrapper
@staticmethod
@_check
async def write(user_id: int, key: str, value):
CacheManager.cache[user_id][key] = value
@staticmethod
@_check
async def extract(user_id: int, key: str):
return CacheManager.cache[user_id][key]
@staticmethod
@_check
async def extract_all(user_id: int):
return CacheManager.cache[user_id]
class Book(CacheManager):
cache = TTLCache(maxsize=200, ttl=900)
data: dict = {
Key.name: False,
Key.str_date: False,
Key.time: False,
Key.location: False,
Key.phone: False,
Key.relation: False,
Key.people: False,
Key.service: False,
Key.service_info: [],
Key.status: False,
Key.delete: False,
Key.chosen_date: datetime.now().date()
}
class Info(CacheManager):
cache = TTLCache(maxsize=300, ttl=3600)
data: dict = {
Key.first_visit: False,
Key.banned: False,
Key.blocked: False,
Key.count: 0,
}