th cache

Create ThailandHosting Cache (works with Redis clients) and Valkey caches, connect with redis-cli or valkey-cli, resize them and manage backups.

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 sizes lists the sizes.
  • th cache connect opens 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

  1. Create it: th cache create sessions --engine valkey.
  2. Allow your own address on the public endpoint: th cache public sessions --enable --allow 203.0.113.7/32.
  3. Connect: th cache connect sessions.
Shell
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 json

Commands

CommandDescription
th cache createCreates a Managed Cache instance.
th cache listLists the Managed Cache instances of the active Project.
th cache describeShows the engine, size, status and addresses of a cache.
th cache enginesLists the engines and versions a new cache can run.
th cache sizesLists the sizes for --size.
th cache connectOpens 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 credentialsPrints the user, password and connection URLs of a cache.
th cache publicTurns the public TLS endpoint on or off.
th cache resizeChanges the size of a cache.
th cache stopStops a cache.
th cache startStarts a stopped cache.
th cache backups createStarts a manual backup.
th cache backups listLists a cache's backups, newest first, and its backup policy.
th cache backups restoreReplaces the cache's data with a backup (by ID or name).
th cache backups deleteDeletes a backup (by ID or name).
th cache backup-policyShows or changes automated backups.
th cache deleteDeletes a cache and its data.

th cache create

Creates a Managed Cache instance.

Syntax

Shell
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

Shell
th cache create sessions --engine valkey

ThailandHosting Cache with a custom size and backups (--engine redis does the same)

Shell
th cache create jobs --engine thcache --cpu 0.5 --memory 1Gi --backups

Positional arguments

NameDescription
NAMERequiredThe cache name.

Parameters

NameTypeDefaultDescription
--engineRequiredstringEngine: thcache|valkey (redis also works and creates a ThailandHosting Cache), or an engine ID from th cache engines
--versionstringthe recommended oneEngine version
--sizestringSize ID from th cache sizes
--cpustringvCPU, e.g. 0.5, 1, 2
--memorystringMemory, e.g. 512Mi, 1Gi, 4Gi
--publicflagOpen a public TLS endpoint (only --allow addresses may connect)
--allowlistAddresses allowed on the public endpoint, e.g. 203.0.113.10/32 (repeatable, comma-separated)
--bandwidthnumberPublic endpoint bandwidth in Mbps (1–1000, default 10)
--backupsflagTurn on automated backups (billed by stored GB)
--backup-hoursnumberBackup every N hours: 6, 12, 24 (default) or 168
--backup-windownumber2Hour backups start, 0–23 Asia/Bangkok
--backup-keepnumber7Automated backups kept, 1–90

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache list

Lists the Managed Cache instances of the active Project.

Syntax

Shell
th cache list

Examples

List caches

Shell
th cache list

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache describe

Shows the engine, size, status and addresses of a cache.

Syntax

Shell
th cache describe NAME

Examples

Engine, size, status and addresses

Shell
th cache describe sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache engines

Lists the engines and versions a new cache can run.

Syntax

Shell
th cache engines

Examples

Engines and versions

Shell
th cache engines

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache sizes

Lists the sizes for --size.

Syntax

Shell
th cache sizes

Examples

Sizes for --size

Shell
th cache sizes

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

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

Shell
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

Shell
th cache connect sessions

Run one command

Shell
th cache connect sessions -- PING

Positional arguments

NameDescription
NAMERequiredThe cache name.
CLIENT-ARGS…OptionalArguments passed to the client after --.

Parameters

NameTypeDefaultDescription
--publicflagUse the public TLS endpoint (default)
--privateflagUse the private address (inside the VPC only)

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache credentials

Prints the user, password and connection URLs of a cache.

Syntax

Shell
th cache credentials NAME [--format json]

The password is shown only to members who may operate it.

Examples

User, password and URLs

Shell
th cache credentials sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache public

Turns the public TLS endpoint on or off.

Syntax

Shell
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

Shell
th cache public sessions --enable --allow 203.0.113.7/32

Close the public endpoint

Shell
th cache public sessions --disable

Positional arguments

NameDescription
NAMERequiredThe cache name.

Parameters

NameTypeDefaultDescription
--enableflagTurn the public endpoint on
--disableflagTurn the public endpoint off
--allowlistAllowed addresses, e.g. 203.0.113.10/32 (repeatable, comma-separated; replaces the list)
--bandwidthnumberBandwidth cap in Mbps (1–1000)

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache resize

Changes the size of a cache.

Syntax

Shell
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)

Shell
th cache resize sessions --memory 2Gi

Positional arguments

NameDescription
NAMERequiredThe cache name.

Parameters

NameTypeDefaultDescription
--sizestringSize ID from th cache sizes
--cpustringvCPU, e.g. 0.5, 1, 2
--memorystringMemory, e.g. 512Mi, 1Gi, 4Gi

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache stop

Stops a cache.

Syntax

Shell
th cache stop NAME

Its storage is kept (and billed); start it again with th cache start.

Examples

Stop it; storage is kept

Shell
th cache stop sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache start

Starts a stopped cache.

Syntax

Shell
th cache start NAME

Examples

Start it again

Shell
th cache start sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache backups create

Starts a manual backup.

Syntax

Shell
th cache backups create NAME

Backups are billed by stored GB.

Examples

Back up now

Shell
th cache backups create sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache backups list

Lists a cache's backups, newest first, and its backup policy.

Syntax

Shell
th cache backups list NAME

Examples

Backups and the policy

Shell
th cache backups list sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache backups restore

Replaces the cache's data with a backup (by ID or name).

Syntax

Shell
th cache backups restore NAME BACKUP [--quiet]

--quiet skips the prompt.

Examples

Replace the data with a backup

Shell
th cache backups restore sessions <backup-id>

Positional arguments

NameDescription
NAMERequiredThe cache name.
BACKUPRequiredA backup, by ID or name, from th cache backups list.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache backups delete

Deletes a backup (by ID or name).

Syntax

Shell
th cache backups delete NAME BACKUP [--quiet]

--quiet skips the prompt.

Examples

Delete a backup

Shell
th cache backups delete sessions <backup-id>

Positional arguments

NameDescription
NAMERequiredThe cache name.
BACKUPRequiredA backup, by ID or name, from th cache backups list.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache backup-policy

Shows or changes automated backups.

Syntax

Shell
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

Shell
th cache backup-policy sessions --enable --hours 24 --keep 7

Positional arguments

NameDescription
NAMERequiredThe cache name.

Parameters

NameTypeDefaultDescription
--enableflagTurn automated backups on
--disableflagTurn automated backups off
--hoursnumberBack up every N hours: 6, 12, 24 or 168
--windownumberHour backups start, 0–23 (Asia/Bangkok)
--keepnumberAutomated backups kept, 1–90

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th cache delete

Deletes a cache and its data.

Syntax

Shell
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

Shell
th cache delete sessions

Positional arguments

NameDescription
NAMERequiredThe cache name.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑