Cache
provide.foundation.transport.cache
¶
TODO: Add module docstring.
Classes¶
TransportCache
¶
Transport cache with automatic health-based eviction.
Tracks transport health and automatically evicts transports that exceed the failure threshold. This prevents cascading failures from unhealthy transports.
Functions¶
clear
¶
Clear all cached transports.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of evicted transports for cleanup |
Source code in provide/foundation/transport/cache.py
evict
¶
Evict transport from cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheme
|
str
|
Transport scheme to evict |
required |
Source code in provide/foundation/transport/cache.py
get_health
¶
Get health status for scheme.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheme
|
str
|
Transport scheme |
required |
Returns:
| Type | Description |
|---|---|
TransportHealth | None
|
TransportHealth or None if not tracked |
Source code in provide/foundation/transport/cache.py
get_or_create
async
¶
Get or create transport for scheme.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheme
|
str
|
Transport scheme (e.g., "http", "https") |
required |
factory
|
Callable[[str], Any]
|
Factory function to create new transport |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Transport instance |
Raises:
| Type | Description |
|---|---|
TransportCacheEvictedError
|
If transport was evicted due to failures |
Source code in provide/foundation/transport/cache.py
is_evicted
¶
mark_failure
¶
Mark a failed request for scheme.
Automatically evicts transport if failure threshold is exceeded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheme
|
str
|
Transport scheme |
required |
error
|
Exception
|
Error that occurred |
required |