# RedisCache

> **Class** in `langchain_community`

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

Cache that uses Redis as a backend. Allows to use a sync `redis.Redis` client.

## Signature

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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `redis_` | `Any` | Yes | An instance of a Redis client class (`redis.Redis`) to be used for caching. This allows the object to communicate with a Redis server for caching operations. |
| `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

- `_RedisCacheBase`

## 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/RedisCache/lookup)
- [`update()`](https://reference.langchain.com/python/langchain-community/cache/RedisCache/update)
- [`clear()`](https://reference.langchain.com/python/langchain-community/cache/RedisCache/clear)

---

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