跳转至

缓存系统

CachePolicy

zerograph.cache.CachePolicy dataclass

Configuration for node-level caching.

字段说明:

字段 类型 默认值 说明
key_func Callable[[str, Any], str] None 自定义缓存键生成函数
ttl float None 缓存有效期(秒)

BaseCache

zerograph.cache.BaseCache

Bases: ABC

Abstract base class for cache backends.

get abstractmethod

get(key: str) -> Any | None

Retrieve a cached value by key. Returns None if not found or expired.

set abstractmethod

set(key: str, value: Any, ttl: float | None = None) -> None

Store a value with optional TTL override.

clear abstractmethod

clear() -> None

Remove all cached entries.

InMemoryCache

zerograph.cache.InMemoryCache

Bases: BaseCache

In-memory cache with TTL support.

__init__

__init__() -> None

get

get(key: str) -> Any | None

set

set(key: str, value: Any, ttl: float | None = None) -> None

clear

clear() -> None