# Cache (/docs/products/dash-dots/reference/dash-api/cache)

A dot's own key-value cache, apart from its files. It holds up to 64 MB of JSON values, each kept until removed or until its `ttl` runs out.

## `dash.storage.cache.get`

```ts
dash.storage.cache.get<Value extends CacheValue = CacheValue>(key: string, callOptions?: CallOptions): DashRequest<Value | null>
```

Resolves with null for a missing or expired key.

Types: [`CacheValue`](/docs/products/dash-dots/reference/dash-api/cache#cachevalue)

## `dash.storage.cache.set`

```ts
dash.storage.cache.set(key: string, value: CacheValue, options?: CacheSetOptions, callOptions?: CallOptions): DashRequest<void>
```

Saves `value` under `key`. Give `{ ttl }` in milliseconds to have it expire, such as 60 000 for a minute; without it, the value stays until you remove it.

Types: [`CacheValue`](/docs/products/dash-dots/reference/dash-api/cache#cachevalue), [`CacheSetOptions`](/docs/products/dash-dots/reference/dash-api/cache#cachesetoptions)

## `dash.storage.cache.remove`

```ts
dash.storage.cache.remove(key: string, callOptions?: CallOptions): DashRequest<void>
```

Deletes the value saved under `key`.

## `dash.storage.cache.exists`

```ts
dash.storage.cache.exists(key: string, callOptions?: CallOptions): DashRequest<boolean>
```

Whether a value is saved under `key` and hasn't expired.

## `dash.storage.cache.keys`

```ts
dash.storage.cache.keys(callOptions?: CallOptions): DashRequest<string[]>
```

Every key with a value that hasn't expired, sorted.

## `dash.storage.cache.clear`

```ts
dash.storage.cache.clear(callOptions?: CallOptions): DashRequest<void>
```

Deletes everything in the dot's cache.

## Types

### `CacheValue`

```ts
type CacheValue = string | number | boolean | CacheValue[] | { [key: string]: CacheValue };
```

### `CacheSetOptions`

| Field            | Type     | What it is                                                                                    |
| ---------------- | -------- | --------------------------------------------------------------------------------------------- |
| `ttl` (optional) | `number` | How many milliseconds the entry lasts. Without it, or with 0 or less, it lasts until removed. |
