---
title: "Create a cache"
description: "Choose an engine, mode, size, storage and standby, decide who can connect, and set the maintenance window."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a cache

## Before you start

A cache needs a [subnet](/private-networks/vpcs) of a VPC. It's reached only from inside the VPC:
there's no public address.

Its first user's password goes to a new [Secret](/secrets) in the project, written as you, so
creating a cache also needs `secrets.secrets.create` and `secrets.versions.create` in the project.

## Create

### Console

1. Open **Caches** and choose **Create cache**.
2. Pick **Valkey** or **Memcached**, a version, and on Valkey a mode.
3. Pick a size, a subnet, and whether to have a standby. A persistent cache also needs storage.
4. Check the summary, then choose **Create cache**.
### CLI

```sh
ezgh caches create wp-cache --engine valkey --engine-version 9.1 --mode memory \
  --instance-type gp-1.large --subnet sbn_2m9x0a7qpe4k --wait
```

```sh
ezgh caches create sessions --engine valkey --engine-version 9.1 --mode persistent \
  --instance-type gp-1.xlarge --storage-size-gib 20 --standby --subnet sbn_2m9x0a7qpe4k --wait
```

```sh
ezgh caches create wp-memcached --engine memcached --engine-version 1.6 \
  --instance-type gs-1.large --subnet sbn_2m9x0a7qpe4k --wait
```

A create takes minutes, and `--wait` waits until the cache is `available`. The cache exists from the
start, `creating`, with its ID (`cch_…`). Its `endpoint` is `null` until the name resolves.

The cache comes with one user, `default`, whose password is in a Secret. See [Users](/caches/users).

## Settings

| Setting | |
| --- | --- |
| `engine` | `valkey` or `memcached`. Fixed. |
| `engineVersion` | Valkey `8.1` or `9.1`, Memcached `1.6`. `ezgh caches engine-versions` lists them. [Upgrades](/caches/upgrades) move to a newer one. |
| `mode` | `memory` or `persistent` (Valkey only). Fixed; a [blue/green deployment](/caches/upgrades) can change it. |
| `instanceType` | The cache's size, a `gp-1` or `gs-1` type. The cache's memory follows from it. Can change later. |
| `standby` | `true` for a [standby](/caches/standby-and-failover). `false` by default. Can change later. |
| `storage` | Persistent caches only: `sizeGiB`, and optionally `iops` and `throughputMBps`. |
| `subnet` | The subnet it's in. Fixed. |
| `allowedSourceCidrs` | [Who can connect](#who-can-connect). |
| `plaintextPort` | Memcached only: whether port 11212 serves without TLS. On by default. |
| `parameters` | Engine settings, below. |
| `maintenance.windowUtc` | The [maintenance window](#maintenance). |
| `deletionProtection` | Refuses deletes while on. |

### Parameters

Valkey caches evict the least recently used keys when memory is full (`maxmemory-policy` is
`allkeys-lru`), as an object cache expects. `ezgh caches engine-versions` lists the parameters each
engine takes, such as `maxmemory-policy` and `timeout` on Valkey and the largest item size on
Memcached.

```sh
ezgh caches update cch_4k2m9x0a7qpe --parameter maxmemory-policy=volatile-lru
```

### Storage

A persistent cache's storage can grow while the cache serves, and can't shrink:

```sh
ezgh caches update cch_4k2m9x0a7qpe --storage-size-gib 40 --wait
```

When it's full, Valkey refuses writes and the cache is `storage_full` until you grow it.

## Who can connect

A cache's `allowedSourceCidrs` are the IPv4 CIDRs that may connect to it. Left out, they're the VPC's
ranges. The list replaces the previous one when you change it, with no interruption:

```sh
ezgh caches update cch_4k2m9x0a7qpe --allowed-source-cidr 10.0.1.0/24 --allowed-source-cidr 10.0.2.0/24
```

Your instances' [firewalls](/compute/firewalls) must allow their traffic to the cache. A firewall that
allows all outbound traffic, as a new one does, needs nothing more. Otherwise, add an outbound rule
whose peer is the cache:

```json
{
  "direction": "outbound",
  "protocol": "tcp",
  "ports": { "from": 6379, "to": 6379 },
  "peer": { "cache": "cch_4k2m9x0a7qpe" }
}
```

A cache needs 2 free addresses in its subnet, or 3 with a standby; a create in a subnet without them is
refused with `409 subnet_has_no_room`. A subnet or VPC with a cache in it can't be deleted: that's
`409 cache_in_use`, naming the cache.

## Maintenance

Engine patch releases and other updates are applied in the cache's maintenance window. The window is
`ddd:HH:MM-ddd:HH:MM` in UTC, at least 30 minutes long, for example `sun:04:00-sun:04:30`; it may run
past the end of the week (`sat:23:45-sun:00:15`). Each cache gets a default window, which you can change:

```sh
ezgh caches update cch_4k2m9x0a7qpe --maintenance-window sun:04:00-sun:04:30
```

- **Valkey**: writes pause for a few seconds and open connections end; clients reconnect to the same
  endpoint. The data stays.
- **Memcached**: the cache starts empty after maintenance.

Maintenance that can't wait may be applied outside the window, and is listed in the cache's
[events](/caches/monitoring#events). Changes you make yourself apply when you make them.

Source: https://docs.ezghcloud.com/caches/create/index.mdx
