|
| 1 | +from .asyncx import * |
| 2 | +from privex.helpers import plugin as plugin |
| 3 | +from privex.helpers.asyncx import await_if_needed as await_if_needed, awaitable as awaitable, loop_run as loop_run |
| 4 | +from .CacheAdapter import CacheAdapter as CacheAdapter |
| 5 | +from .MemoryCache import MemoryCache as MemoryCache |
| 6 | +from .RedisCache import RedisCache as RedisCache |
| 7 | +from .SqliteCache import SqliteCache as SqliteCache |
| 8 | +from privex.helpers.common import LayeredContext as LayeredContext, empty_if as empty_if |
| 9 | +from privex.helpers.exceptions import CacheNotFound as CacheNotFound, NotConfigured as NotConfigured |
| 10 | +from privex.helpers.settings import DEFAULT_CACHE_TIMEOUT as DEFAULT_CACHE_TIMEOUT |
| 11 | +from typing import Any, Optional, Type, Union |
| 12 | + |
| 13 | +log: Any |
| 14 | +CLSCacheAdapter = Union[Type[CacheAdapter], Type[AsyncCacheAdapter]] |
| 15 | +INSCacheAdapter = Union[CacheAdapter, AsyncCacheAdapter] |
| 16 | +ANYCacheAdapter = Union[CLSCacheAdapter, INSCacheAdapter] |
| 17 | + |
| 18 | +class CacheWrapper: |
| 19 | + cache_instance: Optional[INSCacheAdapter] = ... |
| 20 | + default_adapter: Type[CLSCacheAdapter] = ... |
| 21 | + instance_args: Any = ... |
| 22 | + instance_kwargs: Any = ... |
| 23 | + max_context_layers: int = ... |
| 24 | + @classmethod |
| 25 | + def get_context_tracker(cls: Any, reset: bool=...) -> LayeredContext: ... |
| 26 | + @classmethod |
| 27 | + def reset_context_tracker(cls: Any) -> LayeredContext: ... |
| 28 | + @classmethod |
| 29 | + def get_adapter(cls: Any, default: CLSCacheAdapter=..., *args: Any, **kwargs: Any) -> INSCacheAdapter: ... |
| 30 | + @classmethod |
| 31 | + def set_adapter(cls: Any, adapter: ANYCacheAdapter, *args: Any, **kwargs: Any) -> INSCacheAdapter: ... |
| 32 | + @classmethod |
| 33 | + def reset_adapter(cls: Any, default: CLSCacheAdapter=..., *args: Any, **kwargs: Any) -> INSCacheAdapter: ... |
| 34 | + def __getattr__(self, item: Any): ... |
| 35 | + def __getitem__(self, item: Any): ... |
| 36 | + def __setitem__(self, key: Any, value: Any): ... |
| 37 | + async def __aenter__(self): ... |
| 38 | + async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): ... |
| 39 | + def __enter__(self): ... |
| 40 | + def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): ... |
| 41 | + |
| 42 | +cached: Union[CacheAdapter, CacheWrapper] |
| 43 | + |
| 44 | +class AsyncCacheWrapper(CacheWrapper): |
| 45 | + cache_instance: AsyncCacheAdapter = ... |
| 46 | + instance_args: Any = ... |
| 47 | + instance_kwargs: Any = ... |
| 48 | + default_adapter: Type[AsyncCacheAdapter] = ... |
| 49 | + max_context_layers: int = ... |
| 50 | + @classmethod |
| 51 | + def get_adapter(cls: Any, default: Type[AsyncCacheAdapter]=..., *args: Any, **kwargs: Any) -> AsyncCacheAdapter: ... |
| 52 | + @classmethod |
| 53 | + def set_adapter(cls: Any, adapter: AsyncCacheAdapter, *args: Any, **kwargs: Any) -> AsyncCacheAdapter: ... |
| 54 | + @classmethod |
| 55 | + def reset_adapter(cls: Any, default: Type[AsyncCacheAdapter]=..., *args: Any, **kwargs: Any) -> AsyncCacheAdapter: ... |
| 56 | + def __getattr__(self, item: Any): ... |
| 57 | + def __getitem__(self, item: Any): ... |
| 58 | + def __setitem__(self, key: Any, value: Any): ... |
| 59 | + def __enter__(self): ... |
| 60 | + def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): ... |
| 61 | + |
| 62 | +async_cached: Union[AsyncCacheAdapter, AsyncCacheWrapper] |
| 63 | + |
| 64 | +def async_adapter_set(adapter: AsyncCacheAdapter) -> AsyncCacheAdapter: ... |
| 65 | +def async_adapter_get(default: Type[AsyncCacheAdapter]=...) -> AsyncCacheAdapter: ... |
| 66 | +def adapter_set(adapter: CacheAdapter) -> Any: ... |
| 67 | +def adapter_get(default: Type[CacheAdapter]=...) -> CacheAdapter: ... |
| 68 | +def get(key: str, default: Any=..., fail: bool=...) -> Any: ... |
| 69 | +def set(key: str, value: Any, timeout: Optional[int]=...) -> Any: ... |
| 70 | +def get_or_set(key: str, value: Union[Any, callable], timeout: int=...) -> Any: ... |
| 71 | +def remove(*key: str) -> bool: ... |
| 72 | +def update_timeout(key: str, timeout: int=...) -> Any: ... |
0 commit comments