Connect to an instance and enter the interactive shell
redis-cli -h 127.0.0.1 -p 6379High-frequency commands for connections, keys, the five data types, troubleshooting and replication, with blocking and flush warnings.
Connect to an instance and enter the interactive shell
redis-cli -h 127.0.0.1 -p 6379Connect with a password and suppress the plaintext warning
redis-cli -h 127.0.0.1 -p 6379 -a '<PASSWORD>' --no-auth-warningThe password stays in shell history; prefer the REDISCLI_AUTH env var
Test connectivity; returns PONG when healthy
redis-cli -h 127.0.0.1 -p 6379 pingShow memory usage, fragmentation ratio and related metrics
redis-cli -h 127.0.0.1 -p 6379 info memoryCount the keys in the current database
redis-cli -h 127.0.0.1 -p 6379 dbsizeIterate keys in cursor batches without blocking the server
scan 0 match user:* count 100Return every key at once and block the server when keys are many
keys *Do not run in production; use SCAN or redis-cli --scan instead
Show the data type of a key
type user:1001Show the remaining TTL; -1 means the key never expires
ttl session:abcSet the key to expire in 3600 seconds
expire session:abc 3600Delete a big key asynchronously to avoid blocking the main thread
unlink big:cacheDelete every key in the current database; this is unrecoverable
flushdbWipe all databases; never run it by accident in production
flushallSet a string value with a one-hour TTL
set user:1001:name "Tom" ex 3600Atomically increment a counter such as page views
incr page:viewSet hash fields, which suits object storage
hset user:1001 name Tom age 28Read all fields and values of a hash
hgetall user:1001Push an element onto the left side of a list
lpush queue:jobs job1Read all elements of a list
lrange queue:jobs 0 -1Add unique members to a set
sadd tags:post:1 vue redisAdd a member with a score to a sorted set
zadd rank:score 98 tomReturn the top ten members by descending score
zrevrange rank:score 0 9 withscoresShow the last ten slow commands
slowlog get 10Print every command the server receives in real time
monitorVery verbose and slows the instance; stop it right after debugging
Show the memory used by a single key
memory usage user:1001Scan the keyspace and list the biggest key of each type
redis-cli --bigkeysScans the whole keyspace; run it during off-peak hours
Create an RDB snapshot in the background
bgsaveChange the RDB save policy at runtime
config set save "900 1 300 10"In-memory only and lost on restart; run config rewrite to persist it
Turn this instance into a replica of the given master
replicaof 10.0.0.12 6379Show replication role, offset and link status
info replicationShow cluster state, slot coverage and node count
cluster infoList node roles, slot ranges and connection details
cluster nodesShow which hash slot a key maps to
cluster keyslot user:1001Check cluster config, slot coverage and consistency
redis-cli --cluster check 10.0.0.11:6379This website uses cookies to ensure you get the best experience on our website. Privacy Policy.