from abc import ABC, abstractmethod from typing import Any, ClassVar, Dict, Optional from libbot.cache.classes import Cache from pymongo.asynchronous.collection import AsyncCollection class Cacheable(ABC): """Abstract class for cacheable""" __short_name__: str __collection__: ClassVar[AsyncCollection] @classmethod @abstractmethod async def from_id(cls, *args: Any, cache: Optional[Cache] = None, **kwargs: Any) -> Any: pass @abstractmethod async def _set(self, cache: Optional[Cache] = None, **kwargs: Any) -> None: pass @abstractmethod async def _remove(self, *args: str, cache: Optional[Cache] = None) -> None: pass @abstractmethod def _get_cache_key(self) -> str: pass @abstractmethod def _update_cache(self, cache: Optional[Cache] = None) -> None: pass @abstractmethod def _delete_cache(self, cache: Optional[Cache] = None) -> None: pass @staticmethod @abstractmethod def _entry_to_cache(db_entry: Dict[str, Any]) -> Dict[str, Any]: pass @staticmethod @abstractmethod def _entry_from_cache(cache_entry: Dict[str, Any]) -> Dict[str, Any]: pass @abstractmethod def to_dict(self, json_compatible: bool = False) -> Dict[str, Any]: pass @staticmethod @abstractmethod def get_defaults(**kwargs: Any) -> Dict[str, Any]: pass @staticmethod @abstractmethod def get_default_value(key: str) -> Any: pass @abstractmethod async def update( self, cache: Optional[Cache] = None, **kwargs: Any, ) -> None: pass @abstractmethod async def reset( self, *args: str, cache: Optional[Cache] = None, ) -> None: pass @abstractmethod async def purge(self, cache: Optional[Cache] = None) -> None: pass