LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangSmith
  • Client
  • Run Trees
  • Traceable
  • Evaluation
  • Schemas
  • Langchain
  • Jest
  • Vitest
  • Wrappers
  • Anonymizer
  • Traceable
  • Jestlike
  • Vercel
  • Anthropic
  • Sandbox
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangSmith
ClientRun TreesTraceableEvaluationSchemasLangchainJestVitestWrappersAnonymizerTraceableJestlikeVercelAnthropicSandbox
Language
Theme
JavaScriptlangsmithutilsprompt_cacheCache
Class●Since v0.7Deprecated

Cache

Copy
class Cache

Bases

PromptCache

Constructors

Properties

Methods

Inherited fromPromptCache

Properties

PhitRate: numberPmetrics: Readonly<CacheMetrics>Psize: string
—

Storage size (e.g., "1Gi", "10Gi").

PtotalRequests
View source on GitHub
: number

Methods

Mclear
—

Clear all cache entries.

MconfigureMdump
—

Dump cache contents to a JSON file for offline use.

Mget→ PromptCommit | undefined
—

Get a value from cache.

Minvalidate
—

Remove a specific entry from cache.

Mload→ number
—

Load cache contents from a JSON file.

MresetMetrics
—

Reset all metrics to zero.

Mset
—

Set a value in the cache.

MstartRefreshLoop
—

Start the background refresh loop.

Mstop
—

Stop background refresh.

constructor
constructor
property
hitRate: number
property
metrics: Readonly<CacheMetrics>
property
size: string

Storage size (e.g., "1Gi", "10Gi").

property
totalRequests: number
method
clear

Clear all cache entries.

method
configure
method
dump

Dump cache contents to a JSON file for offline use.

method
get→ PromptCommit | undefined

Get a value from cache.

Returns the cached value or undefined if not found. Stale entries are still returned (background refresh handles updates).

method
invalidate

Remove a specific entry from cache.

method
load→ number

Load cache contents from a JSON file.

Loaded entries get a fresh TTL starting from load time.

method
resetMetrics

Reset all metrics to zero.

method
set

Set a value in the cache.

method
startRefreshLoop

Start the background refresh loop.

method
stop

Stop background refresh. Should be called when the client is being cleaned up.