27 lines
950 B
Python
27 lines
950 B
Python
from httpx import Request
|
|
from httpx import Response as HTTPXResponse
|
|
from httpx import _models as m # type: ignore
|
|
|
|
from aiohttpx.responses import Response
|
|
from aiohttpx.transports.rate_limiter import AsyncRateLimit, Redis
|
|
|
|
def generate_cache_key(request: Request) -> str: ...
|
|
def cache_response(
|
|
client: Redis[bytes],
|
|
cache_key: str,
|
|
request: Request,
|
|
response: Response | HTTPXResponse,
|
|
) -> None: ...
|
|
def get_ttl_from_headers(headers: m.Headers) -> int | None: ...
|
|
def get_cached_response(
|
|
client: Redis[bytes], cache_key: str
|
|
) -> Response | None: ...
|
|
def serialize_response(response: Response | HTTPXResponse) -> bytes: ...
|
|
def deserialize_response(serialized_response: bytes) -> Response: ...
|
|
|
|
class AsyncCacheTransport(AsyncRateLimit):
|
|
def __init__(
|
|
self, redis_url: str | None, key: str | None, limit: int | None
|
|
) -> None: ...
|
|
async def handle_async_request(self, request: Request) -> Response: ...
|