Files
fastapi-cache/fastapi_cache/backends/__init__.py

21 lines
602 B
Python
Raw Normal View History

2020-08-26 18:04:57 +08:00
import abc
2022-11-07 16:39:17 +08:00
from typing import Optional, Tuple
2020-08-26 18:04:57 +08:00
class Backend:
@abc.abstractmethod
2022-10-22 20:59:37 +04:00
async def get_with_ttl(self, key: str) -> Tuple[int, Optional[str]]:
2020-08-26 18:04:57 +08:00
raise NotImplementedError
@abc.abstractmethod
2022-10-22 20:59:37 +04:00
async def get(self, key: str) -> Optional[str]:
2020-08-26 18:04:57 +08:00
raise NotImplementedError
@abc.abstractmethod
2022-10-22 20:59:37 +04:00
async def set(self, key: str, value: str, expire: Optional[int] = None) -> None:
2020-08-26 18:04:57 +08:00
raise NotImplementedError
2020-11-03 18:08:06 +08:00
@abc.abstractmethod
2022-10-22 20:59:37 +04:00
async def clear(self, namespace: Optional[str] = None, key: Optional[str] = None) -> int:
2020-11-03 18:08:06 +08:00
raise NotImplementedError