Skip to content

DocsRun your app

Valkey

Valkey, a fully managed Redis-compatible cache for caching, queues and sessions: on your team's network, attached to any app, backed up every day.

Valkey is a fully managed, Redis-compatible cache: a resource of the team, a Valkey 8 server on a machine of its own with a disk for its data, on your team’s private network. Your apps reach it through the Redis API, with the variables they already know (REDIS_URL, REDIS_HOST, REDIS_PASSWORD and the rest). You attach a cache to any number of your apps; each gets the connection as variables. Unless you switch Sleep when idle off, it sleeps when nothing is connected and wakes on the next connection, so a cache nobody uses costs almost nothing. Its disk is backed up every day.

Every Redis client works with it unchanged: ioredis, node-redis, BullMQ, Bull, connect-redis, Laravel’s Redis driver.

Open Resources, New Valkey cache:

Field What to enter
Name Lower-case letters, digits and dashes, such as cache or queue-store. Unique in the team
Region The region of the app that uses it. A cache in another region adds latency to every call, and it cannot move later
Size 256 MB, 512 MB or 1 GB of memory, as far as your plan allows, see Limits. The data cap is a little under that, see Sizes
Grow up to The largest size it may move to by itself. The largest size your plan allows unless you lower it
Eviction policy What it does when the data reaches the cap: noeviction (refuse writes) unless you pick another, see Eviction policy

The dialog says what the size costs before you create it with Create cache. A cache past the number your plan allows is refused with “Your Hobby plan allows 1 Valkey cache. Switch plan to add more.” (during the trial: “The free trial allows 1 Valkey cache. Choose a plan to add more.”), a size past its largest with “Your Hobby plan allows caches of up to 512 MB. Switch plan for a bigger one.” (during the trial: “The free trial allows caches of up to 256 MB. Choose a plan for a bigger one.”). The cache is ready in about a minute; its page says when.

On the cache’s page, Attach to an app, pick the app and a variable prefix: REDIS unless the app has one already. The app gets five variables, set by the platform like PORT:

Variable Value
REDIS_URL redis://default:password@host:6379
REDIS_HOST The cache’s own host name, a name of ours. It connects only from the team’s network
REDIS_PORT 6379
REDIS_USERNAME default, the one user a cache has; Laravel’s REDIS_USERNAME reads it
REDIS_PASSWORD The password

They reach the app with its next redeploy: the pill next to the app’s status says New resources, and Redeploy now applies it. The five are set by the platform, listed under Variables in Provided by the platform; the values of the password and the URL are readable only by the owner and the admins, like a Config variable’s value. Detach takes the five variables off again, with the next redeploy.

Two caches on one app get two prefixes: REDIS_URL for the first, REDIS_QUEUE_STORE_URL for the one named queue-store, or any prefix you type.

import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
// BullMQ
const queue = new Queue('emails', { connection: { url: process.env.REDIS_URL } });
  • On your team’s network. The host is a name of ours that points at a private address: the team’s apps, workers and cron jobs reach it, nothing else does, and it has no address on the internet unless you open it to the outside. The password is still required.
  • Persistent. Every write goes to a log on the disk within a second, and a snapshot is taken every few minutes. A restart, a change of size or a move to another machine loses at most the last second.
  • Full means full, unless you choose otherwise. When the data reaches the cap of the size, the cache refuses writes rather than dropping keys (noeviction), so a queue never loses jobs silently. Reads keep working. Before that happens it grows, see below. A cache that holds only data your app can make again can drop keys instead, see Eviction policy.
  • One copy. A cache runs on one machine. It is for cached data, sessions and queues, not for the data of record: keep that in a database.
Size Holds up to Running, per hour Running, a month at most Persistence, a month
256 MB 205 MB $0.0061 $4.45 $0.45
512 MB 410 MB $0.0103 $7.49 $0.75
1 GB 880 MB $0.0186 $13.58 $1.05

Running prices are for US East; other regions follow their compute price. The rest of the memory is the server’s own, and the two small sizes have swap so a snapshot during a burst of writes never runs out of memory.

At 90% of its data cap a cache moves to the next size, up to the Grow up to you set and never past the largest size your plan allows, and the team is told. The move restarts it on the same disk for a few seconds; the data stays, and the price changes from that hour. A cache at the largest size it may grow to and nearly full is told to the team instead, and again every six hours while it stays so: remove keys, or raise Grow up to.

A cache whose eviction policy drops keys does not grow by itself: it sits near its cap by design, and growing would only raise the bill. Raise its size yourself if keys are dropped too soon.

Change the size yourself on the cache’s page. A smaller size is refused while the data would not fit in it, and a bigger one past the largest size your plan allows. A cache that is already bigger than your plan allows keeps its size.

The eviction policy decides what the cache does when the data reaches the cap of its size: refuse new writes, or drop keys to make room for them. Pick it under Eviction policy in the New Valkey cache dialog; a new cache keeps noeviction unless you pick another.

Policy When the cache is full
noeviction (Recommended, the default) Refuses writes; reads keep working and nothing is dropped, so queues and sessions are never lost silently
allkeys-lru (Best for a pure cache) Drops the keys used least recently, of all keys
volatile-lru Drops the keys used least recently, of the keys with an expiry
allkeys-random Drops keys at random, of all keys
volatile-random Drops keys at random, of the keys with an expiry
volatile-ttl Drops the keys whose expiry is nearest, of the keys with an expiry
allkeys-lfu Drops the keys used least often, of all keys
volatile-lfu Drops the keys used least often, of the keys with an expiry
  • Keep noeviction for a queue (BullMQ, Laravel’s queue), sessions, or anything your app cannot make again: a write that does not fit is refused with an error your app sees, instead of a job or a session going missing.
  • Pick allkeys-lru when everything in the cache can be made again, such as cached pages or query results: writes keep working when it is full, and the keys nobody has read for a while make room.
  • The volatile- policies drop only keys that have an expiry. Keys without one are never dropped: once only those are left, writes are refused as with noeviction. They suit a cache that mixes expiring cached data with keys that must stay.

Change it later on the cache’s page, in the card Eviction policy, with Save, once the cache is ready. The change applies at once, without a restart: connections stay open and the data stays. It is kept when the cache restarts, sleeps and wakes, changes size or is restored from a backup. A sleeping cache stays asleep and wakes with the new policy.

While the policy drops keys (anything but noeviction), the cache does not grow by itself. Such a cache sits near its cap by design, so the team is told once that it is nearly full, in words that say it drops keys to make room rather than that writes will be refused, and not again every six hours; a new policy is told once again. Back on noeviction, a nearly full cache grows to the next size at its next check, up to its Grow up to, and its price changes from then. The policy costs nothing extra. Caches made before the setting existed keep noeviction.

The cache’s page charts what the cache holds and serves, over the last hour up to the days your plan keeps (how far back you can look), in UTC:

Group Charts
Data Memory the data takes, against the cap of the size; keys; disk used. The header says how many writes were refused because it was full
Traffic Commands per second, hit rate (the share of reads that found their key), clients connected
Machine Whether it was awake, processor, network in and out

Data and traffic are read from the cache itself every five minutes while it runs, so no point is closer than five minutes and a cache that sleeps leaves a gap. The machine charts come from the platform. The charts reload every minute.

A cache sleeps when no connection is open to it, whatever held the connection, and wakes on the next connection, which waits a second or two. An app that sleeps closes its connections, so a cache used only by that app sleeps too; an app or worker kept always on keeps it awake. Nothing is lost on the way: the write log is on the disk, and the cache wakes with its data.

The switch Sleep when idle on the cache’s page decides whether it sleeps at all. It is on for a new cache.

  • On: the cache sleeps when nothing is connected. Its running time stops and only the persistence fee is charged; the next connection waits a second or two while it wakes.
  • Off: the cache keeps running with nothing connected, so a connection never waits for it. Its running time is charged around the clock.

Any member of the team can change it. The cache shows as changing for a moment while the setting is applied, then ready again; the data stays.

When the team’s apps are paused because the trial or the plan ended, the trial credit is used up or a payment stays unpaid, a cache with the switch off is set to sleep when idle as well, and it is set back once the team may run apps again. A suspended team’s caches are set to sleep when idle too; after the suspension, switch them back yourself. While the team may not run apps, its caches cannot be changed, only deleted.

To reach a cache from your computer, a tool or an app somewhere else, turn on Access from outside on its page. In a minute it also answers at a public host of its own, <id>.public.cache.…, on port 6380, over TLS and with the password. The word “public” keeps it apart from the private host your apps use. The card then lists the public host, the port and the URL (rediss://default:password@<public host>:6380), which the owner and the admins can reveal.

redis-cli --tls --sni <public host> -h <public host> -p 6380 --user default --pass <password> ping
import Redis from 'ioredis';
const redis = new Redis('rediss://default:password@<public host>:6380');
  • The client has to speak TLS and send the host name (SNI): rediss:// URLs do this in ioredis, node-redis and Laravel’s Redis driver; redis-cli needs --tls --sni. A connection without the name, or to the plain port, is refused before it reaches the cache, so nobody who does not know the host can reach or wake it.
  • Your apps keep using the private host. Traffic between them and the cache stays on the team’s network.
  • A connection from outside wakes a sleeping cache like any other.
  • Turned off again, the public host goes and only your apps reach the cache.

Only the owner and the admins switch it. Should the password have been shared too widely, replace it with a new password.

A cache is counted in two parts, both by the hour it exists:

  • Running time, like a replica: per second while the machine runs, at the price of its size and region. Asleep, nothing. With Sleep when idle off it never sleeps, so this runs all month.
  • Persistence, for the disk and the stopped machine, whether it runs or sleeps: $0.45 a month for 256 MB, $0.75 for 512 MB, $1.05 for 1 GB.
  • Backups: $0.16 per GB a month of what the backups hold, counted by the hour. A backup holds what the disk holds, and the days after it hold only what changed, so a small cache’s backups cost a few cents a month.

A cache open to the outside also pays for what it sends out of the platform, per GB at the bandwidth price of its region, on a “Bandwidth” line under the cache. The plan’s free bandwidth counts only the apps’ traffic. Traffic to your own apps is not counted.

A cache asleep all month costs its persistence fee and its backups alone. One running all month costs at most the running price of its size plus the fee and the backups. A cache deleted on the tenth is charged for ten days. The bill has one line per cache, such as “Valkey 256 MB”, with the backups inside; Billing shows the running time and the persistence so far.

Should the password get out, New password on the cache’s page, under Connection, replaces it: the cache restarts with the new one in a few seconds and the old one stops working at that moment. Every attached app gets the new REDIS_URL and REDIS_PASSWORD and is marked for a redeploy; its connections fail until you redeploy it, so do that right after. Only the owner and the admins can do this.

The disk is backed up every day. Keep backups for, in the card on the cache’s page, decides for how many days: 1, 3, 5, 7, 14, 30 (5 unless you change it). A new number applies to the backups taken from then on; the ones before keep their own. Back up now takes one more. Restore puts the data of a backup in place of what is there: the cache is unavailable for a few minutes while it starts on the restored disk, and everything written since that backup is lost. Its address stays the same, so apps need nothing.

The machine’s disk is one disk: should the host it sits on fail, the cache is restored from the last backup, so up to a day of writes can be lost. That is why a cache holds cached data, sessions and queues, and a database holds the data of record.

Delete on the cache’s page, then Delete cache with the name typed to confirm. The machine and the disk go at once, and every attached app loses the five variables with its next redeploy. The platform removes the backups by itself once their days are over; nobody can restore them, and they are not charged. A team with a cache cannot be deleted until the cache is.

  • Sizes: 256 MB, 512 MB and 1 GB.
  • Caches per team, and the largest size one may have or grow to: 1 up to 512 MB on Hobby, 3 up to 1 GB on Pro, 10 up to 1 GB on Business, 1 up to 256 MB during the trial. A lower plan cannot be chosen while the team has more or bigger caches than it allows, see Change the plan.
  • One cache can be attached to any number of the team’s apps.
  • Regions: the ones apps run in. A cache cannot move to another region.

Members create a cache, attach it, resize it, choose its eviction policy, switch Sleep when idle, choose how long backups are kept and back it up. Only the owner and the admins see the password and the URL, replace the password, open a cache to the outside, and delete a cache. See Teams.