Redis keeps its data in memory. It serves as a cache, session storage, a job queue and a pub/sub channel. On Webgune, Redis 7 exists only as a project database, a service in your project with its volume.
| Value | |
|---|---|
| Version | Redis 7 |
| Port | 6379 |
| Authentication | password only (requirepass), no username |
| Persistence | write-ahead log turned on (appendonly yes), plus a snapshot every 60 seconds if there was at least one write |
| Storage | 5 GB volume |
| Resources | at most 1 vCPU and 1 GB of memory, taken from your plan |
| Instances | one only, no sleep mode |
Create a Redis instance
- In the project, New service, then Deploy Redis.
- Fill in a name. The Password is generated if the field is left empty (at least 8 characters otherwise).
- Click Create.
The service's Database tab shows the internal host, the port, the masked password and the connection string.
Connection string
REDIS_URL=redis://:MOT_DE_PASSE@cache.kx-app-1a2b3c4d.svc.cluster.local:6379
The colon before the password is required: the username is empty. The internal address answers only the services of the same project (Network and isolation).
ioredis (Node.js)
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL!);
await redis.set("session:abc", JSON.stringify({ userId: 42 }), "EX", 3600);
const session = await redis.get("session:abc");
redis-py (Python)
import os, redis
r = redis.Redis.from_url(os.environ["REDIS_URL"], decode_responses=True)
r.set("compteur", 0)
r.incr("compteur")
Application cache
async function getUser(id: string) {
const cached = await redis.get(`user:${id}`);
if (cached) return JSON.parse(cached);
const user = await db.user.findUnique({ where: { id } });
await redis.set(`user:${id}`, JSON.stringify(user), "EX", 300);
return user;
}
Give every cache key a time to live (EX). Webgune sets no eviction policy on Redis: without a time to live, the cache grows to the 1 GB limit, then the instance is stopped and restarted.
Job queue
A Redis list with LPUSH and BRPOP hands each job to a single consumer, and the job stays in the list until someone takes it:
// producer (web service)
await redis.lpush("jobs:emails", JSON.stringify({ to, subject }));
// consumer (worker)
const job = await redis.brpop("jobs:emails", 5);
The full example, with graceful shutdown, is on Workers. BullMQ relies on the same Redis instance and adds retries and delayed jobs.
Pub/sub
// publisher
await redis.publish("evenements", JSON.stringify({ type: "commande", id }));
// subscriber: a dedicated connection, used for nothing else
const sub = new Redis(process.env.REDIS_URL!);
await sub.subscribe("evenements");
sub.on("message", (_canal, payload) => handle(JSON.parse(payload)));
A message published when no subscriber is listening is lost. For jobs that must be processed, use a list, not pub/sub.
What survives a restart
| Event | Data |
|---|---|
| Restart, update, server failure | kept: the write-ahead log is on the volume |
| Hard stop | at most the last second of writes may be missing |
| Service deletion | lost along with the volume |
Redis remains in-memory storage limited to 1 GB. Data you cannot recreate elsewhere must not live there alone: a session can be regenerated, an account balance cannot.
Access from your machine
Turn on Public access in the Database tab, then:
redis-cli -h HOTE_PUBLIC -p PORT_PUBLIC -a MOT_DE_PASSE
The public port is open to the whole Internet, with no address list and no TLS: only the password protects the instance. Turn the access off after the intervention.
Commands from the panel
The console in the Database tab runs the command with redis-cli and stops it after 30 seconds. It suggests INFO server by default. The command is split on spaces: a value that contains spaces does not go through the console.
INFO memory
DBSIZE
SCAN 0 MATCH session:* COUNT 100
TTL session:abc
Avoid KEYS * on a busy instance: the command blocks Redis while it walks through all the keys.
Common errors
| Message | Cause | What to do |
|---|---|---|
NOAUTH Authentication required | password missing from the URL | use redis://:MOT_DE_PASSE@... |
WRONGPASS invalid username-password pair | username added, or wrong password | leave the username empty |
ECONNREFUSED or ENOTFOUND | internal address used outside the project, or instance starting | check the project, read the Logs tab |
| Stop with code 137 | memory exceeds 1 GB | add times to live, reduce the data stored |
Updated on