# CosmosDBCache

> **Class** in `langchain_azure_cosmosdb`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache)

Asynchronous CosmosDB implementation of LangGraph BaseCache.

Uses the native ``azure.cosmos.aio`` async client for non-blocking I/O.
Sync methods (``get``, ``set``, ``clear``) delegate to the async
implementations via ``asyncio.run_coroutine_threadsafe``.

## Signature

```python
CosmosDBCache(
    self,
    container: Any,
    *,
    serde: SerializerProtocol | None = None,
)
```

## Description

Use ``from_conn_info`` to create an instance:

**Example:**

>>> async with CosmosDBCache.from_conn_info(
...     endpoint="https://your-account.documents.azure.com:443/",
...     key="your_key",
...     database_name="langgraph_db",
...     container_name="cache",
... ) as cache:
...     result = await cache.aget([(("ns",), "key1")])

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `container` | `Any` | Yes | An already-created async ``ContainerProxy`` instance. |
| `serde` | `SerializerProtocol \| None` | No | Optional custom serializer. (default: `None`) |

## Extends

- `BaseCache[ValueT]`

## Constructors

```python
__init__(
    self,
    container: Any,
    *,
    serde: SerializerProtocol | None = None,
) -> None
```

| Name | Type |
|------|------|
| `container` | `Any` |
| `serde` | `SerializerProtocol \| None` |


## Properties

- `container`

## Methods

- [`from_conn_info()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/from_conn_info)
- [`aget()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/aget)
- [`aset()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/aset)
- [`aclear()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/aclear)
- [`get()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/get)
- [`set()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/set)
- [`clear()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_langgraph_cache/CosmosDBCache/clear)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/e62c2a55aaa0942fdac739b4066011953b80018e/libs/azure-cosmosdb/src/langchain_azure_cosmosdb/aio/_langgraph_cache.py#L26)