# AsyncAzureCosmosDBNoSqlSemanticCache

> **Class** in `langchain_azure_cosmosdb`

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

Async cache that uses Cosmos DB NoSQL backend.

## Signature

```python
AsyncAzureCosmosDBNoSqlSemanticCache(
    self,
    embedding: Embeddings,
    *,
    vector_embedding_policy: Dict[str, Any],
    indexing_policy: Dict[str, Any],
    cosmos_container_properties: Dict[str, Any],
    cosmos_database_properties: Dict[str, Any],
    vector_search_fields: Dict[str, Any],
    database_name: str = 'CosmosNoSqlCacheDB',
    container_name: str = 'CosmosNoSqlCacheContainer',
    search_type: str = 'vector',
    create_container: bool = True,
    score_threshold: float = 0.5,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `embedding` | `Embeddings` | Yes | CosmosDB Embedding. |
| `vector_embedding_policy` | `Dict[str, Any]` | Yes | CosmosDB vector embedding policy. |
| `indexing_policy` | `Dict[str, Any]` | Yes | CosmosDB indexing policy. |
| `cosmos_container_properties` | `Dict[str, Any]` | Yes | CosmosDB container properties. |
| `cosmos_database_properties` | `Dict[str, Any]` | Yes | CosmosDB database properties. |
| `vector_search_fields` | `Dict[str, Any]` | Yes | Vector Search Fields for the container. |
| `database_name` | `str` | No | CosmosDB database name. (default: `'CosmosNoSqlCacheDB'`) |
| `container_name` | `str` | No | CosmosDB container name. (default: `'CosmosNoSqlCacheContainer'`) |
| `search_type` | `str` | No | CosmosDB search type. (default: `'vector'`) |
| `create_container` | `bool` | No | Create the container if it doesn't exist. (default: `True`) |
| `score_threshold` | `float` | No | Threshold for a cache hit. For cosine and dot product, this is the minimum similarity score — results below it are treated as cache misses. For Euclidean, this is the maximum distance — results above it are misses. (default: `0.5`) |

## Extends

- `BaseCache`

## Constructors

```python
__init__(
    self,
    embedding: Embeddings,
    *,
    vector_embedding_policy: Dict[str, Any],
    indexing_policy: Dict[str, Any],
    cosmos_container_properties: Dict[str, Any],
    cosmos_database_properties: Dict[str, Any],
    vector_search_fields: Dict[str, Any],
    database_name: str = 'CosmosNoSqlCacheDB',
    container_name: str = 'CosmosNoSqlCacheContainer',
    search_type: str = 'vector',
    create_container: bool = True,
    score_threshold: float = 0.5,
) -> None
```

| Name | Type |
|------|------|
| `embedding` | `Embeddings` |
| `vector_embedding_policy` | `Dict[str, Any]` |
| `indexing_policy` | `Dict[str, Any]` |
| `cosmos_container_properties` | `Dict[str, Any]` |
| `cosmos_database_properties` | `Dict[str, Any]` |
| `vector_search_fields` | `Dict[str, Any]` |
| `database_name` | `str` |
| `container_name` | `str` |
| `search_type` | `str` |
| `create_container` | `bool` |
| `score_threshold` | `float` |


## Properties

- `database_name`
- `container_name`
- `embedding`
- `vector_embedding_policy`
- `indexing_policy`
- `cosmos_container_properties`
- `cosmos_database_properties`
- `vector_search_fields`
- `search_type`
- `create_container`
- `score_threshold`

## Methods

- [`create()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/create)
- [`lookup()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/lookup)
- [`alookup()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/alookup)
- [`update()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/update)
- [`aupdate()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/aupdate)
- [`clear()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/clear)
- [`aclear()`](https://reference.langchain.com/python/langchain-azure-cosmosdb/aio/_cache/AsyncAzureCosmosDBNoSqlSemanticCache/aclear)

---

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