2024-07-29 20:09:33 -04:00
|
|
|
from typing import ClassVar, Optional
|
2023-11-26 23:48:18 -05:00
|
|
|
|
2024-05-13 23:25:13 -04:00
|
|
|
from .base import BaseCache
|
|
|
|
from .serializers import BaseSerializer
|
2023-11-26 23:48:18 -05:00
|
|
|
|
2024-07-29 20:09:33 -04:00
|
|
|
class Cache[T](BaseCache[T]):
|
2024-05-13 23:25:13 -04:00
|
|
|
MEMORY: ClassVar[type[BaseCache]]
|
|
|
|
REDIS: ClassVar[type[BaseCache] | None]
|
|
|
|
MEMCACHED: ClassVar[type[BaseCache] | None]
|
|
|
|
|
|
|
|
def __new__(
|
|
|
|
cls,
|
|
|
|
cache_class: type[BaseCache] = MEMORY,
|
|
|
|
*,
|
|
|
|
serializer: Optional[BaseSerializer] = None,
|
|
|
|
namespace: str = "",
|
|
|
|
**kwargs,
|
|
|
|
) -> Cache[T]: ...
|
|
|
|
@staticmethod
|
|
|
|
def get_scheme_class(scheme: str) -> type[BaseCache]: ...
|
|
|
|
async def add(self, key: str, value: T, ttl: Optional[int]) -> None: ...
|
|
|
|
async def set(self, key: str, value: T, ttl: Optional[int]) -> None: ... # noqa: A003
|
|
|
|
async def get(self, key: str, default: T | None = None) -> T | None: ...
|