Connect
redis-cli -h <host> -p <port>
Connect to host and port
redis-cli -u
redis://<user>:<pass>@<host>:<port>/<db>
Connect with a URI
Use the rediss:// scheme for TLS; user and db are optional
redis-cli -n <db>
Start in database number
redis-cli -s <socket>
Connect over a Unix socket
redis-cli --user <name> --askpass
Log in, prompt for password
REDISCLI_AUTH=<pass> redis-cli
Pass password via environment
Avoids the password showing in the process list, unlike -a
redis-cli -a <pass>
Authenticate with a password
Prints a warning; silence with --no-auth-warning
redis-cli --tls --cacert <ca.crt>
Connect over TLS
redis-cli --tls --cert <crt> --key <key>
TLS with client certificate
redis-cli -3
Use the RESP3 protocol
redis-cli -c
Follow cluster redirects
redis-cli -t <seconds>
Set connection timeout
CONNECT <host> <port>
Switch server in the prompt
Run and script
redis-cli <command> [args]
Run one command and exit
redis-cli --raw <command>
Plain output without type labels
redis-cli --no-raw <command>
Force typed output when piped
redis-cli --csv <command>
Reply as CSV
redis-cli --json <command>
Reply as JSON
Defaults to RESP3 replies; add -2 for RESP2
redis-cli -x SET <key> < <file>
Use stdin as last argument
redis-cli < <commands.txt>
Run commands from a file
redis-cli -r <n> -i <sec> <command>
Repeat a command
-r -1 repeats forever
redis-cli -e <command>
Exit non-zero on error reply
redis-cli --eval <script.lua> <key> ,
<arg>
Run a Lua script
The comma separates KEYS from ARGV
redis-cli --pipe < <file>
Bulk-load raw protocol
redis-cli --quoted-input <command>
Parse arguments as quoted strings
Keys
EXISTS <key>
Does the key exist
UNLINK <key>
Delete in the background
TYPE <key>
Show the key's type
EXPIRE <key> <seconds>
Set a time to live
TTL <key>
Seconds left (-1 none, -2 gone)
PERSIST <key>
Remove the expiry
RENAME <key> <new>
Rename a key
SCAN <cursor> MATCH <pat> COUNT <n>
Iterate keys in steps
Repeat with the returned cursor until it is 0
DBSIZE
Count keys in this database
OBJECT ENCODING <key>
Internal encoding
MEMORY USAGE <key>
Bytes used by a key
KEYS <pattern>
List matches (blocks server)
O(N) over the whole keyspace; fine on a dev box, risky in
production
FLUSHDB
Delete all keys in this database
FLUSHALL
Delete all keys in all databases
Irreversible; add ASYNC to free memory in the background
Inspect and monitor
INFO <section>
One section (memory, stats, ...)
CLIENT LIST
Show connected clients
SLOWLOG GET 10
Latest slow commands
CONFIG GET <pattern>
Read settings
CONFIG SET <name> <value>
Change a setting at runtime
Not persisted unless you run CONFIG REWRITE
MONITOR
Stream every command
Costly under load; stop with Ctrl+C
redis-cli --stat
Rolling server stats
redis-cli --bigkeys
Largest key per type
redis-cli --memkeys
Largest keys by memory
redis-cli --keystats
Sizes and distribution
redis-cli --scan --pattern '<pat>'
List matching keys
redis-cli --scan --pattern '<pat>' --count
<n>
Scan with larger batches
redis-cli --latency
Measure round-trip time
redis-cli --latency-history
Latency in 15 s windows
redis-cli --intrinsic-latency <sec>
Local system latency test
Run it on the server host, it does not connect
redis-cli --hotkeys
Sample hot keys
Needs an LFU maxmemory-policy
redis-cli --rdb <file>
Download an RDB snapshot
redis-cli --replica
Show the replication stream
redis-cli --cluster help
List cluster manager commands