Caching
langgraph.cache.base
¶
BaseCache
¶
Base class for a cache.
| METHOD | DESCRIPTION |
|---|---|
__init__ |
Initialize the cache with a serializer. |
get |
Get the cached values for the given keys. |
aget |
Asynchronously get the cached values for the given keys. |
set |
Set the cached values for the given keys and TTLs. |
aset |
Asynchronously set the cached values for the given keys and TTLs. |
clear |
Delete the cached values for the given namespaces. |
aclear |
Asynchronously delete the cached values for the given namespaces. |
__init__
¶
__init__(*, serde: SerializerProtocol | None = None) -> None
Initialize the cache with a serializer.
get
abstractmethod
¶
Get the cached values for the given keys.
aget
abstractmethod
async
¶
Asynchronously get the cached values for the given keys.
set
abstractmethod
¶
Set the cached values for the given keys and TTLs.
aset
abstractmethod
async
¶
Asynchronously set the cached values for the given keys and TTLs.
langgraph.cache.memory
¶
InMemoryCache
¶
Bases: BaseCache[ValueT]
| METHOD | DESCRIPTION |
|---|---|
__init__ |
Initialize the cache with a serializer. |
get |
Get the cached values for the given keys. |
aget |
Asynchronously get the cached values for the given keys. |
set |
Set the cached values for the given keys. |
aset |
Asynchronously set the cached values for the given keys. |
clear |
Delete the cached values for the given namespaces. |
aclear |
Asynchronously delete the cached values for the given namespaces. |
__init__
¶
__init__(*, serde: SerializerProtocol | None = None)
Initialize the cache with a serializer.
get
¶
Get the cached values for the given keys.
aget
async
¶
Asynchronously get the cached values for the given keys.
set
¶
Set the cached values for the given keys.
aset
async
¶
Asynchronously set the cached values for the given keys.
langgraph.cache.sqlite
¶
SqliteCache
¶
Bases: BaseCache[ValueT]
File-based cache using SQLite.
| METHOD | DESCRIPTION |
|---|---|
__init__ |
Initialize the cache with a file path. |
get |
Get the cached values for the given keys. |
aget |
Asynchronously get the cached values for the given keys. |
set |
Set the cached values for the given keys and TTLs. |
aset |
Asynchronously set the cached values for the given keys and TTLs. |
clear |
Delete the cached values for the given namespaces. |
aclear |
Asynchronously delete the cached values for the given namespaces. |
__init__
¶
__init__(*, path: str, serde: SerializerProtocol | None = None) -> None
Initialize the cache with a file path.
get
¶
Get the cached values for the given keys.
aget
async
¶
Asynchronously get the cached values for the given keys.
set
¶
Set the cached values for the given keys and TTLs.
aset
async
¶
Asynchronously set the cached values for the given keys and TTLs.