Cache
provide.foundation.tools.cache
¶
TODO: Add module docstring.
Classes¶
CacheError
¶
CacheError(
message: str,
*,
code: str | None = None,
context: dict[str, Any] | None = None,
cause: Exception | None = None,
**extra_context: Any
)
Bases: FoundationError
Raised when cache operations fail.
Source code in provide/foundation/errors/base.py
ToolCache
¶
Cache for installed tools with TTL support.
Tracks installed tool locations and expiration times to avoid unnecessary re-downloads and installations.
Initialize the cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_dir
|
Path | None
|
Cache directory (defaults to ~/.provide-foundation/cache). |
None
|
Source code in provide/foundation/tools/cache.py
Functions¶
clear
¶
get
¶
Get cached tool path if valid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
Tool name. |
required |
version
|
str
|
Tool version. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to cached tool if valid, None otherwise. |
Source code in provide/foundation/tools/cache.py
get_size
¶
Get total size of cached tools in bytes.
Returns:
| Type | Description |
|---|---|
int
|
Total size in bytes. |
Source code in provide/foundation/tools/cache.py
invalidate
¶
Invalidate cache entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
Tool name. |
required |
version
|
str | None
|
Specific version, or None for all versions. |
None
|
Source code in provide/foundation/tools/cache.py
list_cached
¶
List all cached tools.
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of cache entries with metadata. |
Source code in provide/foundation/tools/cache.py
prune_expired
¶
Remove expired entries from cache.
Returns:
| Type | Description |
|---|---|
int
|
Number of entries removed. |
Source code in provide/foundation/tools/cache.py
store
¶
Store tool in cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
Tool name. |
required |
version
|
str
|
Tool version. |
required |
path
|
Path
|
Path to installed tool. |
required |
ttl_days
|
int
|
Time-to-live in days. |
7
|