# GPTCache

> **Class** in `langchain_community`

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

Cache that uses GPTCache as a backend.

## Signature

```python
GPTCache(
    self,
    init_func: Union[Callable[[Any, str], None], Callable[[Any], None], None] = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `init_func` | `Optional[Callable[[Any], None]]` | No | init `GPTCache` function (default: `None`) |
| `(default` | `unknown` | Yes | `None`) |

## Extends

- `BaseCache`

## Constructors

```python
__init__(
    self,
    init_func: Union[Callable[[Any, str], None], Callable[[Any], None], None] = None,
)
```

| Name | Type |
|------|------|
| `init_func` | `Union[Callable[[Any, str], None], Callable[[Any], None], None]` |


## Properties

- `init_gptcache_func`
- `gptcache_dict`

## Methods

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

---

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