redis-cliUse this when Redis is running locally with default host and port.
Comprehensive Redis commands for redis-cli, key lifecycle, strings, expiration, and core operational workflows.
Connect, authenticate, select databases, and inspect the server.
redis-cliUse this when Redis is running locally with default host and port.
redis-cli -h redis.example.com -p 6379redis-cli -h redis.example.com -p 6379 -a 'your-password'redis-cli -u redis://:password@redis.example.com:6379/0redis-cli -h redis.example.com -p 6380 --tls --cacert ca.pemPINGRun inside redis-cli interactive mode, or prefix it with `redis-cli` on the shell.
AUTH your-passwordSELECT 1ECHO 'hello redis'HELLO 3CLIENT LISTINFOINFO memoryINFO replicationDBSIZEMEMORY STATSCOMMAND DOCS GET SET HGETALLKey lookup, iteration, TTLs, rename, and lifecycle operations.
EXISTS user:1DEL cache:page:1 cache:page:2UNLINK huge:hashTYPE session:123KEYS user:*Prefer SCAN in production because KEYS blocks and can be expensive.
SCAN 0 MATCH user:* COUNT 100RANDOMKEYRENAME cache:old cache:newRENAMENX cache:old cache:newEXPIRE session:123 3600PEXPIRE job:1 5000EXPIREAT report:1 1767225600TTL session:123PTTL job:1PERSIST session:123TOUCH user:1 user:2DUMP user:1RESTORE user:1-copy 0 '\x00\x01...'COPY user:1 user:1:backupMOVE user:1 2Simple values, counters, ranges, and conditional set patterns.
SET user:1:name 'Alice'SET session:token 'abc123' EX 3600SET lock:job 'token' NX EX 30GET user:1:nameGETDEL temp:tokenGETEX session:token EX 1800MGET user:1:name user:2:name user:3:nameMSET site:name 'CheatSheet' site:env 'prod'MSETNX a 1 b 2APPEND log:events '
new event'STRLEN user:1:nameINCR page:view:123INCRBY page:view:123 10DECR stock:item:1INCRBYFLOAT account:balance 19.95SETRANGE blob 5 'XYZ'GETRANGE blob 0 9SETBIT feature:flags 7 1GETBIT feature:flags 7BITCOUNT feature:flags