Classes
_CachedValue
2
▼
_CachedValue
2
▼
Attributes
| Name | Type | Description |
|---|---|---|
value |
object
|
— |
expires_at |
float
|
— |
_SharedDeferred
3
▼
Awaitable shared by all consumers for one in-flight cache key.
_SharedDeferred
3
▼
Awaitable shared by all consumers for one in-flight cache key.
Methods
close
0
▼
Discard an unstarted deferred value.
Suspense calls ``close()`` on awaitables …
close
0
▼
def close(self) -> None
Discard an unstarted deferred value.
Suspense callsclose()on awaitables when validation fails before
scheduling them. Removing the in-flight entry keeps a rejected render
from pinning the key forever without poisoning other consumers that
already received the same shared awaitable.
Internal Methods 2 ▼
__init__
4
▼
__init__
4
▼
def __init__(self, cache: DeferredCache, key: str, factory: Callable[[], Awaitable[T]], ttl: float) -> None
Parameters
| Name | Type | Description |
|---|---|---|
cache |
— |
|
key |
— |
|
factory |
— |
|
ttl |
— |
__await__
0
Any
▼
__await__
0
Any
▼
def __await__(self) -> Any
Returns
Any
DeferredCache
4
▼
Small explicit TTL cache for Suspense deferred values.
Use one cache instance per app, service, or…
DeferredCache
4
▼
Small explicit TTL cache for Suspense deferred values.
Use one cache instance per app, service, or route module. The cache stores
successful factory results only. Warm hits return the value synchronously,
soSuspenserenders that value in the initial shell. Misses return an
awaitable, preserving the existing shell-plus-deferred-OOB Suspense path.
Methods
get_or_defer
3
T | Awaitable[T]
▼
Return a cached value if fresh, otherwise an awaitable for *factory*.
``ttl=No…
get_or_defer
3
T | Awaitable[T]
▼
def get_or_defer(self, key: str, factory: Callable[[], Awaitable[T]], *, ttl: float | None = None) -> T | Awaitable[T]
Return a cached value if fresh, otherwise an awaitable for factory.
ttl=None uses the cache default. ttl <= 0bypasses both storage
and in-flight dedupe, which is useful when a caller wants Suspense
deferral without reuse. Exceptions are never cached.
Parameters
| Name | Type | Description |
|---|---|---|
key |
— |
|
factory |
— |
|
ttl |
— |
Default:None
|
Returns
T | Awaitable[T]
delete
1
▼
Remove a cached or in-flight value if present.
delete
1
▼
def delete(self, key: str) -> None
Parameters
| Name | Type | Description |
|---|---|---|
key |
— |
clear
0
▼
Remove all cached and in-flight values.
clear
0
▼
def clear(self) -> None
Internal Methods 1 ▼
__init__
1
▼
__init__
1
▼
def __init__(self, *, default_ttl: float = 300.0) -> None
Parameters
| Name | Type | Description |
|---|---|---|
default_ttl |
— |
Default:300.0
|