About
A Managed Cache keeps data in memory for sessions, caching and counters. It uses the same network setup as a database: a private address inside the Project’s VPC, and an optional public TLS endpoint that only allowed addresses may use.
- Caches are billed by the hour from the Project’s wallet;
th cache sizeslists the sizes. th cache connectopens redis-cli or valkey-cli with the password passed in the environment.- Once the data fills the memory you chose, writes are refused: size with headroom or give keys an expiry.
More in the help centre: How Cache works.
How-to guides
Create a cache and connect
- Create it:
th cache create sessions --engine valkey. - Allow your own address on the public endpoint:
th cache public sessions --enable --allow 203.0.113.7/32. - Connect:
th cache connect sessions.
th cache create sessions --engine valkey
th cache public sessions --enable --allow 203.0.113.7/32
th cache connect sessions
th cache credentials sessions --format jsonCommands
| Command | Description |
|---|---|
th cache create | Creates a Managed Cache instance. |
th cache list | Lists the Managed Cache instances of the active Project. |
th cache describe | Shows the engine, size, status and addresses of a cache. |
th cache engines | Lists the engines and versions a new cache can run. |
th cache sizes | Lists the sizes for --size. |
th cache connect | Opens the engine's own client (psql, mysql/mariadb, redis-cli/valkey-cli) with the credentials passed through the environment, never the command line. |
th cache credentials | Prints the user, password and connection URLs of a cache. |
th cache public | Turns the public TLS endpoint on or off. |
th cache resize | Changes the size of a cache. |
th cache stop | Stops a cache. |
th cache start | Starts a stopped cache. |
th cache backups create | Starts a manual backup. |
th cache backups list | Lists a cache's backups, newest first, and its backup policy. |
th cache backups restore | Replaces the cache's data with a backup (by ID or name). |
th cache backups delete | Deletes a backup (by ID or name). |
th cache backup-policy | Shows or changes automated backups. |
th cache delete | Deletes a cache and its data. |
th cache create
Creates a Managed Cache instance.
Syntax
th cache create NAME --engine thcache|valkey [--version V] [--region R] [--size ID | --cpu N --memory M] [--public --allow CIDR,...] [--backups --backup-hours N --backup-window H --backup-keep N]It is billed by the hour from the Project's wallet; see sizes with: th cache sizes
Examples
A Valkey cache with the recommended version
th cache create sessions --engine valkeyThailandHosting Cache with a custom size and backups (--engine redis does the same)
th cache create jobs --engine thcache --cpu 0.5 --memory 1Gi --backupsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--engineRequired | string | Engine: thcache|valkey (redis also works and creates a ThailandHosting Cache), or an engine ID from th cache engines | |
--version | string | the recommended one | Engine version |
--size | string | Size ID from th cache sizes | |
--cpu | string | vCPU, e.g. 0.5, 1, 2 | |
--memory | string | Memory, e.g. 512Mi, 1Gi, 4Gi | |
--public | flag | Open a public TLS endpoint (only --allow addresses may connect) | |
--allow | list | Addresses allowed on the public endpoint, e.g. 203.0.113.10/32 (repeatable, comma-separated) | |
--bandwidth | number | Public endpoint bandwidth in Mbps (1–1000, default 10) | |
--backups | flag | Turn on automated backups (billed by stored GB) | |
--backup-hours | number | Backup every N hours: 6, 12, 24 (default) or 168 | |
--backup-window | number | 2 | Hour backups start, 0–23 Asia/Bangkok |
--backup-keep | number | 7 | Automated backups kept, 1–90 |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache list
Lists the Managed Cache instances of the active Project.
Syntax
th cache listExamples
List caches
th cache listGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache describe
Shows the engine, size, status and addresses of a cache.
Syntax
th cache describe NAMEExamples
Engine, size, status and addresses
th cache describe sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache engines
Lists the engines and versions a new cache can run.
Syntax
th cache enginesExamples
Engines and versions
th cache enginesGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache sizes
Lists the sizes for --size.
Syntax
th cache sizesExamples
Sizes for --size
th cache sizesGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache connect
Opens the engine's own client (psql, mysql/mariadb, redis-cli/valkey-cli) with the credentials passed through the environment, never the command line.
Syntax
th cache connect NAME [--public | --private] [-- CLIENT-ARGS...]By default it uses the public TLS endpoint, which must be enabled and allow your address. --private uses the private address, which is reachable only from inside the Project's VPC. Arguments after -- go to the client.
Examples
Open redis-cli or valkey-cli
th cache connect sessionsRun one command
th cache connect sessions -- PINGPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
CLIENT-ARGS…Optional | Arguments passed to the client after --. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--public | flag | Use the public TLS endpoint (default) | |
--private | flag | Use the private address (inside the VPC only) |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache credentials
Prints the user, password and connection URLs of a cache.
Syntax
th cache credentials NAME [--format json]The password is shown only to members who may operate it.
Examples
User, password and URLs
th cache credentials sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache public
Turns the public TLS endpoint on or off.
Syntax
th cache public NAME --enable|--disable [--allow CIDR,...] [--bandwidth MBPS]Only addresses in --allow may connect (an empty list lets nobody in); --allow replaces the list. Without --enable or --disable, only the list or bandwidth changes.
Examples
Open to one address
th cache public sessions --enable --allow 203.0.113.7/32Close the public endpoint
th cache public sessions --disablePositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--enable | flag | Turn the public endpoint on | |
--disable | flag | Turn the public endpoint off | |
--allow | list | Allowed addresses, e.g. 203.0.113.10/32 (repeatable, comma-separated; replaces the list) | |
--bandwidth | number | Bandwidth cap in Mbps (1–1000) |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache resize
Changes the size of a cache.
Syntax
th cache resize NAME [--size ID | --cpu N --memory M]A new vCPU or memory restarts it, so connections drop for a moment.
Examples
More memory (restarts once)
th cache resize sessions --memory 2GiPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--size | string | Size ID from th cache sizes | |
--cpu | string | vCPU, e.g. 0.5, 1, 2 | |
--memory | string | Memory, e.g. 512Mi, 1Gi, 4Gi |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache stop
Stops a cache.
Syntax
th cache stop NAMEIts storage is kept (and billed); start it again with th cache start.
Examples
Stop it; storage is kept
th cache stop sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache start
Starts a stopped cache.
Syntax
th cache start NAMEExamples
Start it again
th cache start sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache backups create
Starts a manual backup.
Syntax
th cache backups create NAMEBackups are billed by stored GB.
Examples
Back up now
th cache backups create sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache backups list
Lists a cache's backups, newest first, and its backup policy.
Syntax
th cache backups list NAMEExamples
Backups and the policy
th cache backups list sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache backups restore
Replaces the cache's data with a backup (by ID or name).
Syntax
th cache backups restore NAME BACKUP [--quiet]--quiet skips the prompt.
Examples
Replace the data with a backup
th cache backups restore sessions <backup-id>Positional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
BACKUPRequired | A backup, by ID or name, from th cache backups list. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache backups delete
Deletes a backup (by ID or name).
Syntax
th cache backups delete NAME BACKUP [--quiet]--quiet skips the prompt.
Examples
Delete a backup
th cache backups delete sessions <backup-id>Positional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
BACKUPRequired | A backup, by ID or name, from th cache backups list. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache backup-policy
Shows or changes automated backups.
Syntax
th cache backup-policy NAME [--enable|--disable] [--hours N] [--window H] [--keep N]Without flags it prints the policy. Backups are billed by stored GB.
Examples
Daily backups, keep 7
th cache backup-policy sessions --enable --hours 24 --keep 7Positional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--enable | flag | Turn automated backups on | |
--disable | flag | Turn automated backups off | |
--hours | number | Back up every N hours: 6, 12, 24 or 168 | |
--window | number | Hour backups start, 0–23 (Asia/Bangkok) | |
--keep | number | Automated backups kept, 1–90 |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th cache delete
Deletes a cache and its data.
Syntax
th cache delete NAME [--quiet]--quiet skips the prompt. A cache with deletion protection on must have it turned off in the Console first.
Examples
Delete the cache and its data
th cache delete sessionsPositional arguments
| Name | Description |
|---|---|
NAMERequired | The cache name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.