Skip to main content
Open console

Valkey

Cache and sessions

2 min read

Cache and sessions. Not required for more than one web node, since sessions in the database work across machines too, but faster for both.

Valkey is the open-source fork of Redis and speaks the same protocol. Anything written for Redis (the Drupal redis module, Laravel's redis driver, any Redis client) works against it unchanged. A stack runs one cache: Valkey, Redis or Memcached. Naming a different one replaces it.

Your application finds it at VALKEY_HOST and at REDIS_HOST, on port 6379 (REDIS_PORT). See Variables.

Its memory is sized from your machine: most of a cache machine when it has one to itself, a share of your plan when it sits beside your site. When it is full it evicts the least recently used key (allkeys-lru).

Keeping its data

By default Valkey keeps nothing on disk: a restart, which every change to the stack is, empties it. Sessions in it sign everybody out, and queued jobs are gone. Set VALKEY_PERSISTENCE in vallic.yaml, or for one environment under Service settings:

Value What it keeps When it is full
off (the default) nothing evicts the least recently used key
snapshots a snapshot every few minutes, so a restart comes back warm; what was written since the last one is lost evicts, as a cache does
store every write, synced to disk each second refuses new writes rather than drop a key (noeviction), whatever VALKEY_MAXMEMORY_POLICY says
services:
  - valkey:
      version: '9'
      environment:
        VALKEY_PERSISTENCE: store

Use store when sessions or queues live in it: Laravel's SESSION_DRIVER and QUEUE_CONNECTION at redis, Symfony Messenger's Redis transport, Rails' Action Cable.

  • The data is kept on the machine's own disk, beside the database.
  • store is in the nightly backup, offsite beside the database, and restored from the environment's Backups tab. snapshots is not backed up.
  • Moved to another machine, a cache that keeps its data takes it along, either way (what a move costs). One that keeps nothing starts empty there.
  • On a machine of its own, a persistent Valkey holds less than half the machine, which leaves room for the copy it forks to save. Beside the site it counts twice its memory figure for the same copy. Service settings does not turn it on where the machine has no room for that (what each service needs).

From your own computer, vallic tunnel <env> valkey opens it on 127.0.0.1:6379. See Tunnels.

Versions

Version Status
9.0 Supported, and the default
9.1 Supported
8.1 Supported
8.0 Supported

Pin the version, not the build: name 9.0 and the platform matches it to the current build, so a security rebuild reaches you without anybody editing a repository.

What you can change

In vallic.yaml — what each one does is on Service settings:

services:
  - valkey:
      version: '9.0'
      environment:
        VALKEY_MAXMEMORY_POLICY: …
        VALKEY_DATABASES: …
        VALKEY_PERSISTENCE: …

Anything not on this list refuses the deploy, naming the variable — rather than being accepted and quietly ignored.

Need a hand?

Open a ticket from Support in the console. We answer on the ticket.

Open the console How support works