redis-cli
Command-line interface for Redis servers
TLDR
SYNOPSIS
redis-cli [-h host] [-p port] [-a password] [-n db] [command [args...]]
DESCRIPTION
redis-cli is the command-line interface for Redis, an in-memory data structure store used as database, cache, and message broker. It provides interactive and scripted access to Redis servers.In interactive mode (no command specified), redis-cli presents a prompt for entering commands. Commands follow Redis protocol: command name followed by arguments, with responses displayed immediately.Common operations include key-value storage (GET, SET, DEL), lists (LPUSH, RPOP), sets (SADD, SMEMBERS), hashes (HSET, HGET), and pub/sub messaging (PUBLISH, SUBSCRIBE).The tool supports cluster mode, sentinel connections, and various debugging and monitoring features for Redis administration.
PARAMETERS
-h host
Server hostname (default: 127.0.0.1)-p port
Server port (default: 6379)-a password
Password for AUTH command-n db
Database number to select-u uri
Connect using Redis URI (redis://...)-r count
Repeat command count times-i interval
Interval between repeats (seconds)--scan
List keys using SCAN instead of KEYS--pipe
Transfer raw Redis protocol from stdin--rdb file
Transfer RDB dump from server to file-c
Enable cluster mode (follow -ASK and -MOVED redirections)-s socket
Server socket path (overrides hostname and port)--tls
Establish a secure TLS connection--user username
ACL username for AUTH--pass password
Alias for -a--csv
Output in CSV format--bigkeys
Sample keys looking for keys with many elements--memkeys
Sample keys looking for keys consuming the most memory--cluster command
Execute cluster commands--latency
Monitor latency continuously--stat
Print rolling stats
COMMON COMMANDS
SET key value: Store a valueGET key: Retrieve a valueDEL key: Delete a keyKEYS pattern: Find keys matching patternEXPIRE key seconds: Set key expirationTTL key: Get remaining time to liveFLUSHDB: Delete all keys in current databaseINFO: Server information and statisticsPING: Test connection
CAVEATS
Using KEYS \* on production servers with large datasets can block the server. Use SCAN instead for iterating keys in production.Passwords passed with -a appear in process listings and shell history. Use REDISCLI_AUTH environment variable or interactive AUTH for sensitive environments.Redis databases are numbered 0-15 by default. Use -n to select a database or SELECT command interactively.
SEE ALSO
redis-server(1), redis-benchmark(1), memcached(1)
