from __future__ import annotations
"""Interface for Cache services."""
from typing import Any, Protocol, runtime_checkable
[docs]
@runtime_checkable
class ICacheService(Protocol):
"""Abstract protocol for the Processing Data Cache Service."""
[docs]
def get(self, bucket: str, key: str) -> Any | None:
"""Retrieve data from a specific cache bucket.
Args:
bucket: The cache category (e.g., 'topo', 'geol').
key: Unique key for the parameter set.
Returns:
The cached data or None if not found or expired.
"""
...
[docs]
def set(self, bucket: str, key: str, data: Any, metadata: dict | None = None) -> None:
"""Store data in a specific cache bucket.
Args:
bucket: The cache category.
key: Unique key for the parameter set.
data: The data to cache.
metadata: Optional metadata (e.g., TTL, LOD info).
"""
...
[docs]
def invalidate(self, bucket: str | None = None, key: str | None = None) -> None:
"""Invalidate cache entries.
Args:
bucket: If provided, only invalidate this bucket.
key: If provided, only invalidate this specific key.
"""
...
[docs]
def clear(self) -> None:
"""Clear the entire cache."""
...