Install this version
v0.1.2rune add @rune/redis@0.1.2Manifest hash sha256:daf16068ca6e0b13614925d4b3c499999b30ef60eb3dcc8ff54eb3016126f20f
runebook · rune
Redis adapter for Rune storage with atomic Lua writes and native TTL.
Library Rune. Boilerplate code consumed by other Runes — the host never loads it directly. Install it as a dependency of your own Rune and import from it.
rune add @rune/redis@0.1.2Manifest hash sha256:daf16068ca6e0b13614925d4b3c499999b30ef60eb3dcc8ff54eb3016126f20f
The author declares these capabilities as a guide. Rune scripts run with server access.
No capabilities declared by the author. Rune scripts run with server access.
Use Redis as a database for @rune/storage documents, @rune/web-auth accounts, or a stateful Paper Rune.
rune add @rune/redis
Use a redis: or rediss: URL and Redis 6.2 or newer. The adapter uses atomic Lua writes and Redis-native expiration. Enable Redis persistence if the data must survive a Redis restart.
Set DATABASE_URL in the process environment for this example.
Example URL shape:
redis://127.0.0.1:6379/0
import { connect } from "@rune/redis";
import { document } from "@rune/storage";
const db = await connect(process.env.DATABASE_URL!, {
name: "shared",
prefix: "rune:storage:",
});
const visits = document(db.store, "lobby:visits", () => ({ total: 0 }));
await visits.update(({ total }) => ({ total: total + 1 }));
name registers the open connection for other Runes in the same server process.
For example, RUNE_HOMES_STORAGE=reuse:shared makes Homes use this connection.
Omit the name for a generated name or set it to false for a private connection.
Only the connection owner should call await db.close() when consumers have stopped.
prefix defaults to rune:storage:. Choose a distinct prefix for unrelated applications sharing a Redis database. Expiring records use Redis TTLs, so store.prune() returns zero.
redisStore(client, prefix?) wraps an already connected node-redis-compatible client. db.client exposes the client created by connect. When you wrap a driver yourself, you own its lifecycle. See the shared storage configuration for plugin environment variables and connection modes.