Redis Persistence, Replication, and Cluster Cheat Sheet

RDB, AOF, replication, failover, Lua scripts, functions, and cluster command references for operational Redis use.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Persistence

RDB, AOF, rewrite, and durability-related commands.

Read time of last successful save

Return the Unix timestamp of last successful save.

bashANYredispersistencelastsave
bash
LASTSAVE

Rewrite AOF in background

Compact the append-only file in the background.

bashANYredisaofrewrite
bash
BGREWRITEAOF

Wait for replicas to acknowledge writes

Block until writes reach a minimum number of replicas or timeout.

bashANYredisreplicationdurability
bash
WAIT 1 5000

Wait for local AOF fsync

Wait for AOF persistence conditions when supported.

bashANYredisaofdurability
bash
WAITAOF 1 1000 5000

Replication and failover

Replica setup, role inspection, and controlled failover.

Make server replicate from a primary

Turn the current node into a replica of a primary.

bashANYredisreplicationreplicaof
bash
REPLICAOF 10.0.0.10 6379

Promote a replica

Stop replicating and promote current node to primary.

bashANYredisreplicationpromote
bash
REPLICAOF NO ONE

Inspect node role

Return whether this node is primary, replica, or sentinel and related metadata.

bashANYredisreplicationrole
bash
ROLE

Trigger coordinated failover

Ask a primary to hand off leadership to a replica.

bashANYredisreplicationfailover
bash
FAILOVER

Partial resynchronization handshake

Replication handshake command used internally by replicas.

bashANYredisreplicationinternal
bash
PSYNC ? -1

Lua scripts and functions

Server-side execution for atomic workflows and reusable logic.

Run a Lua script

Execute Lua server-side atomically.

bashANYredisluaeval
bash
EVAL "return redis.call('GET', KEYS[1])" 1 user:1:name

Run a cached Lua script by SHA

Execute a previously loaded Lua script.

bashANYredisluaevalsha
bash
EVALSHA <sha1> 1 user:1:name

Load a Lua script

Cache a Lua script and return its SHA1.

bashANYredisluascript
bash
SCRIPT LOAD "return 1"

Check cached scripts

Check whether one or more scripts are cached.

bashANYredisluascript
bash
SCRIPT EXISTS <sha1>

Clear cached scripts

Remove all cached Lua scripts.

bashANYredisluascript
bash
SCRIPT FLUSH

Load a Redis function library

Load a function library into the server.

bashANYredisfunctionlua
bash
FUNCTION LOAD "#!lua name=mylib
redis.register_function('ping', function() return 'pong' end)"

List loaded function libraries

Inspect currently loaded libraries and functions.

bashANYredisfunctioninspect
bash
FUNCTION LIST

Call a registered function

Execute a loaded Redis function.

bashANYredisfunctionexecute
bash
FCALL ping 0

Delete a function library

Remove a loaded function library.

bashANYredisfunctionadmin
bash
FUNCTION DELETE mylib

Cluster basics

Redis Cluster slot inspection and cluster-aware operations.

Inspect cluster state

Read cluster state, slot coverage, and message counters.

bashANYredisclusterinspect
bash
CLUSTER INFO

List cluster nodes

Show known cluster nodes and flags.

bashANYredisclusterinspect
bash
CLUSTER NODES

Inspect slot mapping

Return slot-to-node ownership information.

bashANYredisclusterinspect
bash
CLUSTER SLOTS

Compute key hash slot

Compute the cluster slot for a key.

bashANYredisclusterslot
bash
CLUSTER KEYSLOT user:{42}:profile

Count keys in a slot

Count how many keys exist in one slot.

bashANYredisclusterslot
bash
CLUSTER COUNTKEYSINSLOT 1234

Allow replica reads in cluster mode

Tell a cluster replica connection to serve reads.

bashANYredisclusterreplica
bash
READONLY

Return to normal read/write routing

Disable READONLY mode on a cluster connection.

bashANYredisclusterreplica
bash
READWRITE

Accept an ASK redirection

Send ASKING before a redirected command during slot migration.

bashANYredisclustermigration
bash
ASKING

Recommended next

No recommendations yet.