# MongoDBCache

> **Class** in `langchain_mongodb`

📖 [View in docs](https://reference.langchain.com/python/langchain-mongodb/cache/MongoDBCache)

MongoDB Atlas cache

A cache that uses MongoDB Atlas as a backend

## Signature

```python
MongoDBCache(
    self,
    connection_string: str,
    collection_name: str = 'default',
    database_name: str = 'default',
    **kwargs: Dict[str, Any] = {},
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection_name` | `str` | No | Name of collection for cache to live. Defaults to "default". (default: `'default'`) |
| `connection_string` | `str` | Yes | Connection URI to MongoDB Atlas. Defaults to "default". |
| `database_name` | `str` | No | Name of database for cache to live. Defaults to "default". (default: `'default'`) |

## Extends

- `BaseCache`

## Constructors

```python
__init__(
    self,
    connection_string: str,
    collection_name: str = 'default',
    database_name: str = 'default',
    **kwargs: Dict[str, Any] = {},
) -> None
```

| Name | Type |
|------|------|
| `connection_string` | `str` |
| `collection_name` | `str` |
| `database_name` | `str` |


## Properties

- `PROMPT`
- `LLM`
- `RETURN_VAL`
- `client`
- `database`
- `collection`

## Methods

- [`close()`](https://reference.langchain.com/python/langchain-mongodb/cache/MongoDBCache/close)
- [`lookup()`](https://reference.langchain.com/python/langchain-mongodb/cache/MongoDBCache/lookup)
- [`update()`](https://reference.langchain.com/python/langchain-mongodb/cache/MongoDBCache/update)
- [`clear()`](https://reference.langchain.com/python/langchain-mongodb/cache/MongoDBCache/clear)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-mongodb/blob/ad9050c28e092b335dcb846f77c0ec2245553f79/libs/langchain-mongodb/langchain_mongodb/cache.py#L23)