# MomentoCache

> **Class** in `langchain_community`

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

Cache that uses Momento as a backend. See https://gomomento.com/

## Signature

```python
MomentoCache(
    self,
    cache_client: momento.CacheClient,
    cache_name: str,
    *,
    ttl: Optional[timedelta] = None,
    ensure_cache_exists: bool = True,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `cache_client` | `CacheClient` | Yes | The Momento cache client. |
| `cache_name` | `str` | Yes | The name of the cache to use to store the data. |
| `ttl` | `Optional[timedelta]` | No | The time to live for the cache items. Defaults to None, ie use the client default TTL. (default: `None`) |
| `ensure_cache_exists` | `bool` | No | Create the cache if it doesn't exist. Defaults to True. (default: `True`) |

## Extends

- `BaseCache`

## Constructors

```python
__init__(
    self,
    cache_client: momento.CacheClient,
    cache_name: str,
    *,
    ttl: Optional[timedelta] = None,
    ensure_cache_exists: bool = True,
)
```

| Name | Type |
|------|------|
| `cache_client` | `momento.CacheClient` |
| `cache_name` | `str` |
| `ttl` | `Optional[timedelta]` |
| `ensure_cache_exists` | `bool` |


## Properties

- `cache_client`
- `cache_name`
- `ttl`

## Methods

- [`from_client_params()`](https://reference.langchain.com/python/langchain-community/cache/MomentoCache/from_client_params)
- [`lookup()`](https://reference.langchain.com/python/langchain-community/cache/MomentoCache/lookup)
- [`update()`](https://reference.langchain.com/python/langchain-community/cache/MomentoCache/update)
- [`clear()`](https://reference.langchain.com/python/langchain-community/cache/MomentoCache/clear)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/d5ea8358933260ad48dd31f7f8076555c7b4885a/libs/community/langchain_community/cache.py#L877)