sec_interp.core.data_cache module¶
- class sec_interp.core.data_cache.DataCache¶
Bases:
objectCache for storing processed profile data.
This cache stores topographic, geological, and structural profile data to avoid redundant processing when parameters haven’t changed.
Initialize empty cache.
- __init__() None¶
Initialize empty cache.
- get_cache_key(params: Dict[str, Any]) str¶
Generate a unique cache key from parameters.
- Parameters:
params – Dictionary of input parameters
- Returns:
String representation of the parameters hash
- get(key: str) Dict[str, Any] | None¶
Get all cached data for a key.
- Parameters:
key – Cache key
- Returns:
Dictionary with profile_data, geol_data, struct_data or None if not found
- set(key: str, data: Dict[str, Any]) None¶
Set all cache data for a key.
- Parameters:
key – Cache key
data – Dictionary containing profile_data, geol_data, etc.
- get_topographic_profile(key: str) list[tuple[float, float]] | None¶
Get cached topographic profile data.
- Parameters:
key – Cache key (typically hash of input parameters)
- Returns:
Cached profile data or None if not found
- set_topographic_profile(key: str, data: list[tuple[float, float]]) None¶
Store topographic profile data in cache.
- Parameters:
key – Cache key
data – Profile data to cache
- get_geological_profile(key: str) list[GeologySegment] | None¶
Get cached geological profile data.
- Parameters:
key – Cache key
- Returns:
Cached geology data or None if not found
- set_geological_profile(key: str, data: list[GeologySegment]) None¶
Store geological profile data in cache.
- Parameters:
key – Cache key
data – Geology data to cache
- get_structural_data(key: str) list[StructureMeasurement] | None¶
Get cached structural data.
- Parameters:
key – Cache key
- Returns:
Cached structure data or None if not found
- set_structural_data(key: str, data: list[StructureMeasurement]) None¶
Store structural data in cache.
- Parameters:
key – Cache key
data – Structure data to cache
- get_metadata(key: str) Dict[str, Any] | None¶
Get cached metadata for a profile.
- Parameters:
key – Cache key
- Returns:
Cached metadata or None if not found
- set_metadata(key: str, metadata: Dict[str, Any]) None¶
Store metadata for a profile.
- Parameters:
key – Cache key
metadata – Metadata dictionary to cache
- invalidate(pattern: str | None = None) None¶
Invalidate cache entries.
- Parameters:
pattern – Optional pattern to match keys. If None, clears all cache.
- clear() None¶
Clear all cached data.
- get_cache_size() Dict[str, int]¶
Get the size of each cache.
- Returns:
Dictionary with cache names and their sizes