# UpstashRedisCache

> **Class** in `langchain_community`

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

Cache that uses Upstash Redis as a backend.

## Signature

```python
UpstashRedisCache(
    self,
    redis_: Any,
    *,
    ttl: Optional[int] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `redis_` | `Any` | Yes | An instance of Upstash Redis client class (e.g., Redis) used for caching. This allows the object to communicate with Redis server for caching operations on. |
| `ttl` | `int` | No | Time-to-live (TTL) for cached items in seconds. If provided, it sets the time duration for how long cached items will remain valid. If not provided, cached items will not have an automatic expiration. (default: `None`) |

## Extends

- `BaseCache`

## Constructors

```python
__init__(
    self,
    redis_: Any,
    *,
    ttl: Optional[int] = None,
)
```

| Name | Type |
|------|------|
| `redis_` | `Any` |
| `ttl` | `Optional[int]` |


## Properties

- `redis`
- `ttl`

## Methods

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

---

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