LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Graphs
  • Functional API
  • Pregel
  • Checkpointing
  • Storage
  • Caching
  • Types
  • Runtime
  • Config
  • Errors
  • Constants
  • Channels
  • Agents
LangGraph CLI
LangGraph SDK
LangGraph Supervisor
LangGraph Swarm
โŒ˜I

LangChain Assistant

Ask a question to get started

Enter to sendโ€ขShift+Enter new line

Menu

OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
LangGraph CLI
LangGraph SDK
LangGraph Supervisor
LangGraph Swarm
Language
Theme
PythonlanggraphtypesCachePolicy
Classโ—Since v0.2

CachePolicy

Configuration for caching nodes.

Copy
CachePolicy(
  self,
  *,
  key_func: KeyFuncT = default_cache_key,
  ttl: int | None = None

Bases

Generic[KeyFuncT]

Used in Docs

  • Graph API overview
  • Use the functional API
  • Use the graph API

Constructors

Attributes

View source on GitHub
)
constructor
__init__
NameType
key_funcKeyFuncT
ttlint | None
attribute
key_func: KeyFuncT
attribute
ttl: int | None

Function to generate a cache key from the node's input. Defaults to hashing the input with pickle.

Time to live for the cache entry in seconds. If None, the entry never expires.