Functions
get_cache
0
CacheBackend | None
▼
Return the current cache backend. None if no cache configured.
get_cache
0
CacheBackend | None
▼
def get_cache() -> CacheBackend | None
Returns
CacheBackend | None
set_cache
1
None
▼
Set the cache backend for the current context.
set_cache
1
None
▼
def set_cache(backend: CacheBackend) -> None
Parameters
| Name | Type | Description |
|---|---|---|
backend |
CacheBackend |
create_backend
2
CacheBackend
▼
Create a cache backend by name.
create_backend
2
CacheBackend
▼
def create_backend(name: str, **kwargs: Any) -> CacheBackend
Parameters
| Name | Type | Description |
|---|---|---|
name |
str |
|
**kwargs |
Any |
Returns
CacheBackend
cache_view
2
Callable[[Callable[..., …
▼
Decorator to cache a view's response.
Usage::
@app.route("/products")
…
cache_view
2
Callable[[Callable[..., …
▼
def cache_view(ttl: int = 300, key_func: Callable[..., str] | None = None) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Decorator to cache a view's response.
Usage::
@app.route("/products")
@cache_view(ttl=300)
async def products():
...
Parameters
| Name | Type | Description |
|---|---|---|
ttl |
int |
Default:300
|
key_func |
Callable[..., str] | None |
Default:None
|
Returns
Callable[[Callable[..., Any]], Callable[..., Any]]