faust.web.cache

Caching.

class faust.web.cache.Cache(timeout: Optional[Union[timedelta, float, str]] = None, include_headers: bool = False, key_prefix: Optional[str] = None, backend: Optional[Union[Type[CacheBackendT], str]] = None, **kwargs: Any)[source]

Cache interface.

ident: ClassVar[str] = 'faustweb.cache.view'
view(timeout: Optional[Union[timedelta, float, str]] = None, include_headers: bool = False, key_prefix: Optional[str] = None, **kwargs: Any) Callable[[Callable], Callable][source]

Decorate view to be cached.

Return type:

_CallableGenericAlias[_CallableType, _CallableType]

async get_view(key: str, view: View) Optional[Response][source]

Get cached value for HTTP view request.

Return type:

_UnionGenericAlias[Response, None]

async set_view(key: str, view: View, response: Response, timeout: Optional[Union[timedelta, float, str]] = None) None[source]

Set cached value for HTTP view request.

Return type:

None

can_cache_request(request: Request) bool[source]

Return True if we can cache this type of HTTP request.

Return type:

bool

can_cache_response(request: Request, response: Response) bool[source]

Return True for HTTP status codes we CAN cache.

Return type:

bool

key_for_request(request: Request, prefix: Optional[str] = None, method: Optional[str] = None, include_headers: bool = False) str[source]

Return a cache key created from web request.

Return type:

str

build_key(request: Request, method: str, prefix: str, headers: Mapping[str, str]) str[source]

Build cache key from web request and environment.

Return type:

str