ccproxy.pricing.cache¶
ccproxy.pricing.cache
¶
Pricing cache management for dynamic model pricing.
PricingCache
¶
Manages caching of model pricing data from external sources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings
|
PricingSettings
|
Pricing configuration settings |
required |
Source code in ccproxy/pricing/cache.py
is_cache_valid
¶
Check if cached pricing data is still valid.
Returns:
Type | Description |
---|---|
bool
|
True if cache exists and is not expired |
Source code in ccproxy/pricing/cache.py
load_cached_data
¶
Load pricing data from cache.
Returns:
Type | Description |
---|---|
dict[str, Any] | None
|
Cached pricing data or None if cache is invalid/corrupted |
Source code in ccproxy/pricing/cache.py
download_pricing_data
async
¶
Download fresh pricing data from source URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout
|
int | None
|
Request timeout in seconds (uses settings default if None) |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any] | None
|
Downloaded pricing data or None if download failed |
Source code in ccproxy/pricing/cache.py
save_to_cache
¶
Save pricing data to cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
Pricing data to cache |
required |
Returns:
Type | Description |
---|---|
bool
|
True if successfully saved, False otherwise |
Source code in ccproxy/pricing/cache.py
get_pricing_data
async
¶
Get pricing data, from cache if valid or by downloading fresh data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force_refresh
|
bool
|
Force download even if cache is valid |
False
|
Returns:
Type | Description |
---|---|
dict[str, Any] | None
|
Pricing data or None if both cache and download fail |
Source code in ccproxy/pricing/cache.py
clear_cache
¶
Clear cached pricing data.
Returns:
Type | Description |
---|---|
bool
|
True if cache was cleared successfully |
Source code in ccproxy/pricing/cache.py
get_cache_info
¶
Get information about cache status.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Dictionary with cache information |