LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    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

    LangGraph Checkpoint
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdkcachecache_set
    Function●Since v0.3

    cache_set

    Set a value in the cache.

    Copy
    cache_set(
      key: str,
      value: Any,
      *,
      ttl: timedelta | None = None
    

    Used in Docs

    • Use server-side caching
    View source on GitHub
    )
    ->
    None

    Parameters

    NameTypeDescription
    key*str
    value*Any
    ttltimedelta | None
    Default:None

    Requires Agent Server runtime version 0.7.29 or later.

    The cache key.

    The value to cache (must be JSON-serializable).

    Optional time-to-live. Capped at 1 day; None or zero defaults to 1 day.