11. The cache add-on
The cache is a separate Redis beside your database, with its own address, its own password and its own plan.
It is not connected to your database. It starts empty and stays empty until your code puts something in it. The usual pattern is: ask the cache first; if the value is there, use it; if not, query the database and store a copy in the cache with an expiry. Delete the cached copy whenever you change the data it describes.
| Fact | Detail |
|---|---|
| Persistence | None. If its container is replaced by a machine failure, a restart or a plan change, it comes back empty. Store only data you can rebuild, such as sessions or cached query results |
| Backups and failover | None |
| When full | The least recently used keys are removed to make room |
| TLS | Required. There is no unencrypted port. Verify it with the same certificate file as the database |
| Who can connect | The same Network Access list as the database |
Add, change or remove the cache
Open your project on the dashboard, then the deployment, and use the Cache Add-on section.
| To | Do this |
|---|---|
| Add a cache | Pick a plan, optionally type a password, and select Enable cache. It is reachable in a minute or two |
| See its password | Select Reveal password |
| Change its size | Select Change plan, pick a plan and select Save. The cache comes back empty |
| Remove it | Select Disable cache, then Disable. Everything in it is lost |
Once enabled, the section shows its Plan, Endpoint and Max Memory.
A cache password you choose must be 12 to 128 characters, with no spaces, tabs or line breaks, and none of # " ' \. Leave it blank to have one generated.
Script 11.1: Test the cache from the command line
redis-cli -h <cache host> -p <cache port> \
--tls --cacert /etc/ssl/certs/multiconnect-db-ca.pem \
-a "$CACHE_PASSWORD" PING
A working cache answers PONG.

