On Runtime, a paused sandbox keeps Redis's dataset in memory. Redis has no
persistence configured. A pause saves the machine's memory and running
processes. A cache, a queue or an agent's scratch state is therefore there,
unchanged, when the sandbox wakes, while you have credit. Every sandbox is a
Firecracker microVM with its own kernel. A test that runs FLUSHALL touches
only its own server. An 8 GiB sandbox holding a large dataset costs
$0.06125 an hour while nothing queries it. That is
memory at $0.0075 a GiB-hour, plus the 50-millicore CPU floor
(pricing).
Versions on 25 October 2026
| Source | Redis version | Install |
|---|---|---|
Ubuntu 24.04 (redis-server) |
7.0.15 | sudo apt-get install -y redis-server |
Redis's apt repository (packages.redis.io) |
8.10.2 | add the repository, then sudo apt-get install -y redis |
| Clients | redis-py 8.1.0 on PyPI; redis 6.3.0 and ioredis 6.0.0 on npm |
pip install, npm install |
Start Redis and use it
The package installs a service. Redis's own documentation says the service starts after installation and at boot. The samples check that Redis answers before they continue, and start it if it does not.
TypeScriptimport { Sandbox } from "withruntime";await using sbx = await Sandbox.create({ timeoutSeconds: 1800 });await sbx.exec("sudo apt-get update -qq && sudo apt-get install -y -qq redis-server", { check: true, timeoutMs: 600_000,});await sbx.exec("redis-cli ping | grep -q PONG || sudo systemctl start redis-server", { check: true,});await sbx.exec("pip install --quiet redis==8.1.0", { check: true, timeoutMs: 300_000 });await sbx.files.write( "/workspace/worker.py", [ "import redis", "r = redis.Redis(decode_responses=True)", "for n in range(1, 6):", " r.rpush('jobs', f'job-{n}')", "done = [r.lpop('jobs') for _ in range(r.llen('jobs'))]", "print(len(done), 'jobs processed')", ].join("\n"),);const run = await sbx.exec("python3 worker.py", { check: true });console.log(run.stdout);console.log((await sbx.exec("redis-cli info memory | grep used_memory_human")).stdout);Pythonfrom withruntime import Sandboxwith Sandbox.create(timeout_seconds=1800) as sbx: sbx.exec("sudo apt-get update -qq && sudo apt-get install -y -qq redis-server", check=True, timeout_ms=600_000) sbx.exec("redis-cli ping | grep -q PONG || sudo systemctl start redis-server", check=True) sbx.exec("redis-cli set greeting hello", check=True) print(sbx.exec("redis-cli get greeting", check=True).stdout) # hello sbx.exec("redis-cli --rdb /workspace/dump.rdb", check=True) # a point-in-time copy sbx.files.download("/workspace/dump.rdb", "dump.rdb")redis-cli --rdb transfers an RDB dump from the server to a file that the
sandbox user owns. The data can then go home with you or into another Redis.
Code in the sandbox reaches the server on 127.0.0.1:6379. Nothing on the
internet can connect to a sandbox unless you open a way in.
Redis 8 from Redis's own repository
Redis's install guide for Ubuntu adds its signed repository. On a sandbox,
lsb_release -cs prints noble:
Terminalsudo apt-get install -y lsb-release curl gpgcurl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpgsudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpgecho "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.listsudo apt-get update && sudo apt-get install -y redisIt downloads over HTTPS, which a sandbox without credit may use. If Redis does
not answer afterwards, the guide's fix is sudo systemctl enable redis-server
and sudo systemctl start redis-server.
Park it, wake it, find the data still there
TypeScriptimport { Sandbox } from "withruntime";const cache = await Sandbox.getOrCreate("agent-cache", { image: "redis", idlePauseSeconds: 600 });await cache.exec("redis-cli set last-run $(date +%s)", { check: true });// Ten quiet minutes later the sandbox pauses by itself; billing moves to storage.// Tomorrow, from any process:const again = await Sandbox.getOrCreate("agent-cache");console.log((await again.exec("redis-cli get last-run")).stdout);getOrCreate returns the sandbox that holds the name. It wakes the sandbox
first if the sandbox is paused. The same call works the first time and every
time after. The redis image is built in the last section. A paused sandbox is
billed as storage: $0.08 per GB a month for the disk and
memory it alone holds (pause and resume).
Inspect it from your machine
Terminalruntime sandboxes port-forward agent-cache 16379:6379redis-cli -p 16379 monitorRedisInsight or any other client connects to 127.0.0.1:16379 the same way.
The forward goes through Runtime's API with your key. It works without credit
(forward ports). The SDKs have the same call as
sbx.forwardPort(6379) and sbx.forward_port(6379).
Redis in every sandbox
Build Redis into a custom image. The service then starts with each sandbox made from that image:
TypeScriptimport { Runtime } from "withruntime";const runtime = new Runtime();await runtime.images.build({ name: "redis", recipe: { apt: ["redis-server"], pip: ["redis==8.1.0"] },});await using sbx = await runtime.sandboxes.create({ image: "redis", memoryMiB: 8192 });Pythonfrom withruntime import Runtimeruntime = Runtime()runtime.images.build(name="redis", recipe={"apt": ["redis-server"], "pip": ["redis==8.1.0"]})sbx = runtime.sandboxes.create(image="redis", memory_mib=8192)A sandbox gets the memory you ask for. Redis holds its data in that memory. Size
memoryMiB for the dataset, and keep Redis's maxmemory below it. Without
credit, a sandbox has up to 4 GiB.
For Redis next to Postgres and your API, see Docker Compose integration tests. For a database with a disk that outlives sandboxes, see PostgreSQL in a sandbox.
Sources
- Redis, install on Ubuntu with APT, https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/apt/, read 25 October 2026
- Ubuntu 24.04 redis-server package, from the noble-updates universe index at http://archive.ubuntu.com/ubuntu/dists/noble-updates/universe/binary-amd64/, read 25 October 2026
- Redis apt repository index, https://packages.redis.io/deb/dists/noble/main/binary-amd64/Packages, read 25 October 2026
- PyPI redis, https://pypi.org/project/redis/, and npm, https://registry.npmjs.org/redis and https://registry.npmjs.org/ioredis, read 25 October 2026
Facts on this page were checked on 25 October 2026.