Skip to main content

The cache (Valkey)

Each environment can run one cache: Valkey, an open-source server that speaks the Redis protocol, so any Redis client library works with it. The panel and the configuration document call it redis.

One per environment​

An environment has exactly one cache, shared by every application in it. It is a single instance with no replicas, and it runs inside the environment's shared Pod, so it restarts when that Pod is replaced.

Connecting an application​

Name the cache in your application's env with the {redis: attribute} reference and the platform delivers the value — see What an environment value may reference:

env:
REDIS_URL:
redis: url
REDIS_HOST:
redis: host
REDIS_PORT:
redis: port

The plaintext port is 6379. A cache that requires TLS is reached at rediss:// on port 6380, and its certificate authority is delivered to the application at /run/hosting/redis/ca.crt. The endpoints that actually exist for your environment are shown beside its databases — see The cache.

Limits​

  • Shared key space. When authentication is disabled, any application in the environment can read and write any key without a password. With authentication required, applications need the generated cache credential. Use a key prefix per application to avoid collisions; a prefix is not access control.
  • Bounded memory. The cache's memory ceiling follows its own memory allocation, and when it is full it evicts the least recently used keys (allkeys-lru).
  • Inside the environment only. It is not reachable from the internet.

Not a database​

Treat everything in the cache as disposable: it can be lost and rebuilt at any time, unless you chose the append-only file, which keeps a copy through a restart. Keep anything you cannot rebuild in a database, which is backed up.