Add a cache

Add a Redis cache that Ghaym runs for you, and let the project's services reach it.

Add the cache

  1. Open the project, press ⌘K and choose Add service › Redis.

    With the CLI:

    Terminal
    ghaym cloud services create --project shop --type cache --engine redis --name cache --db-size <size> --site <slug>
  2. Pick the version, then type the name and press Enter. Then pick the site the cache runs in, which can't change later, and the size if there is more than one.

    Redis comes in 7 and 8; 8 is picked first. ghaym cloud engines list lists the engines Ghaym runs and their versions. The sizes are 512 MB and 1 GB, and each has its own price.

Reach it from your services

A cache's values reach a website only through a variable the website shows. Set the variable to a reference: ${{cache.REDIS_URL}} reads the REDIS_URL of the cache named cache.

Redis provides REDIS_URL, REDIS_READER_URL, REDIS_HOST, REDIS_PORT and REDIS_PASSWORD.

While a website references none of a cache's variables, its variables page says cache isn't wired to this service. Choose Add REDIS_URL there to stage the reference in one step.

With the CLI, set the reference on a website yourself:

Terminal
ghaym cloud vars set REDIS_URL '${{cache.REDIS_URL}}' --project shop --env production --service web

A cache can run readers, as a database can. Backups cover databases only, not caches.

Check it

Open the cache. Under Connection, Inside the project shows the host and port your services use. To open the cache from your laptop, connect through a tunnel.

Terminal
ghaym cloud services connection cache