Here the list of the most commond redis cli commands

Connection & Info

  • redis-cli – Connect to Redis server (default localhost:6379)
  • redis-cli -h <host> -p <port> – Connect to specific host/port
  • redis-cli --tls -u <conn_string> --cacert name.crt – Connect using TLS and CA
  • PING – Test connection (returns PONG)
  • INFO – Get server statistics and information
  • CONFIG GET * – View all configuration parameters

Key Operations

  • KEYS * – List all keys (avoid in production – use SCAN instead)
  • SCAN 0 – Iterate through keys safely in production
  • EXISTS <key> – Check if key exists
  • DEL <key> – Delete a key
  • TYPE <key> – Get the data type of a key
  • TTL <key> – Get time to live in seconds
  • EXPIRE <key> <seconds> – Set expiration time
  • PERSIST <key> – Remove expiration from key
  • RENAME <oldkey> <newkey> – Rename a key

String Operations

  • SET <key> <value> – Set a string value
  • SET <key> <value> EX <seconds> – Set with expiration (replaces SETEX)
  • SET <key> <value> NX – Set only if not exists (replaces SETNX)
  • GET <key> – Get a string value
  • GETSET <key> <value> – Set and return old value
  • INCR <key> – Increment integer value by 1
  • DECR <key> – Decrement integer value by 1
  • INCRBY <key> <increment> – Increment by specific amount
  • INCRBYFLOAT <key> <increment> – Increment by float
  • MGET <key1> <key2> ... – Get multiple values
  • APPEND <key> <value> – Append to string
  • STRLEN <key> – Get string length
  • GETRANGE <key> <start> <end> – Get substring
  • SETRANGE <key> <offset> <value> – Overwrite part of string

Hash Operations

  • HSET <key> <field> <value> – Set hash field (also accepts multiple field-value pairs)
  • HGET <key> <field> – Get hash field value
  • HGETALL <key> – Get all fields and values
  • HDEL <key> <field> – Delete hash field
  • HKEYS <key> – Get all field names
  • HVALS <key> – Get all values
  • HLEN <key> – Get number of fields
  • HEXISTS <key> <field> – Check if field exists
  • HINCRBY <key> <field> <increment> – Increment hash field
  • HSCAN <key> <cursor> – Iterate hash fields

List Operations

  • LPUSH <key> <value> – Push to list head
  • RPUSH <key> <value> – Push to list tail
  • LPOP <key> – Pop from list head
  • RPOP <key> – Pop from list tail
  • LRANGE <key> <start> <stop> – Get range of elements (use LRANGE key 0 -1 for all)
  • LLEN <key> – Get list length
  • LINDEX <key> <index> – Get element by index
  • LSET <key> <index> <value> – Set element by index
  • LINSERT <key> BEFORE|AFTER <pivot> <value> – Insert element
  • LTRIM <key> <start> <stop> – Trim list to range
  • BLPOP <key> <timeout> – Blocking pop from head
  • BRPOP <key> <timeout> – Blocking pop from tail
  • RPOPLPUSH <source> <dest> – Pop from one list, push to another
  • BRPOPLPUSH <source> <dest> <timeout> – Blocking version

Set Operations

  • SADD <key> <member> – Add member to set
  • SMEMBERS <key> – Get all set members
  • SISMEMBER <key> <member> – Check if member exists
  • SREM <key> <member> – Remove member from set
  • SCARD <key> – Get set cardinality (size)
  • SDIFF <key1> <key2> – Set difference
  • SINTER <key1> <key2> – Set intersection
  • SUNION <key1> <key2> – Set union
  • SDIFFSTORE <dest> <key1> <key2> – Store difference result
  • SINTERSTORE <dest> <key1> <key2> – Store intersection result
  • SUNIONSTORE <dest> <key1> <key2> – Store union result
  • SPOP <key> – Remove and return random member
  • SRANDMEMBER <key> <count> – Get random member(s)
  • SSCAN <key> <cursor> – Iterate set members

Sorted Set Operations

  • ZADD <key> <score> <member> – Add member with score
  • ZRANGE <key> <start> <stop> – Get range by index
  • ZRANGEBYSCORE <key> <min> <max> – Get range by score
  • ZREM <key> <member> – Remove member
  • ZCARD <key> – Get sorted set size
  • ZCOUNT <key> <min> <max> – Count members in score range
  • ZINCRBY <key> <increment> <member> – Increment member score
  • ZRANK <key> <member> – Get member rank (ascending)
  • ZREVRANK <key> <member> – Get member rank (descending)
  • ZSCORE <key> <member> – Get member score
  • ZREVRANGE <key> <start> <stop> – Get range in reverse order
  • ZREMRANGEBYRANK <key> <start> <stop> – Remove by rank range
  • ZREMRANGEBYSCORE <key> <min> <max> – Remove by score range
  • ZUNIONSTORE <dest> <numkeys> <key...> – Union of sorted sets
  • ZINTERSTORE <dest> <numkeys> <key...> – Intersection of sorted sets
  • ZSCAN <key> <cursor> – Iterate sorted set members
  • ZPOPMIN <key> <count> – Pop members with lowest scores
  • ZPOPMAX <key> <count> – Pop members with highest scores

Pub/Sub (Messaging)

  • PUBLISH <channel> <message> – Send message to channel
  • SUBSCRIBE <channel> – Subscribe to channel(s)
  • PSUBSCRIBE <pattern> – Subscribe using pattern matching
  • UNSUBSCRIBE <channel> – Unsubscribe from channel
  • PUBSUB CHANNELS – List active channels
  • PUBSUB NUMSUB <channel> – Get subscriber count for channels

Transactions

  • MULTI – Start transaction block
  • EXEC – Execute all commands in transaction
  • DISCARD – Cancel transaction
  • WATCH <key> – Watch key for optimistic locking
  • UNWATCH – Clear all watched keys

Scripting (Lua)

  • EVAL <script> <numkeys> <key...> <arg...> – Execute Lua script
  • EVALSHA <sha1> <numkeys> <key...> <arg...> – Execute cached script
  • SCRIPT LOAD <script> – Load script into cache
  • SCRIPT EXISTS <sha1> – Check if script is cached
  • SCRIPT FLUSH – Remove all cached scripts
  • SCRIPT KILL – Kill running script

Bit Operations (Bitmaps)

  • SETBIT <key> <offset> <value> – Set bit at offset
  • GETBIT <key> <offset> – Get bit at offset
  • BITCOUNT <key> – Count set bits
  • BITOP AND|OR|XOR|NOT <destkey> <key...> – Bitwise operations
  • BITPOS <key> <bit> – Find first bit set/clear

HyperLogLog (Cardinality Estimation)

  • PFADD <key> <element...> – Add elements
  • PFCOUNT <key...> – Get approximate count
  • PFMERGE <destkey> <sourcekey...> – Merge HyperLogLogs

Geospatial

  • GEOADD <key> <long> <lat> <member> – Add location
  • GEODIST <key> <member1> <member2> <unit> – Get distance
  • GEOSEARCH <key> FROMLONLAT <long> <lat> BYRADIUS <radius> <unit> – Query by radius from coordinates
  • GEOSEARCH <key> FROMMEMBER <member> BYRADIUS <radius> <unit> – Query by radius from member
  • GEOPOS <key> <member> – Get coordinates
  • GEOHASH <key> <member> – Get geohash string

Streams (Event Sourcing)

  • XADD <key> * <field> <value> – Add entry to stream
  • XREAD STREAMS <key> <id> – Read from stream
  • XRANGE <key> <start> <end> – Get range of entries
  • XLEN <key> – Get stream length
  • XGROUP CREATE <key> <group> <id> – Create consumer group
  • XREADGROUP GROUP <group> <consumer> STREAMS <key> > – Read as consumer
  • XACK <key> <group> <id> – Acknowledge message
  • XPENDING <key> <group> – Check pending messages

Database & Admin

  • SELECT <db> – Switch to database number (0-15 by default)
  • FLUSHDB – Clear current database
  • FLUSHALL – Clear all databases
  • DBSIZE – Get number of keys in current database
  • MONITOR – Watch all commands in real-time (debug only)
  • SAVE – Synchronous save to disk
  • BGSAVE – Background save to disk

Memory & Performance

  • MEMORY USAGE <key> – Get memory used by key
  • MEMORY STATS – Memory allocation stats
  • MEMORY DOCTOR – Memory usage report
  • SLOWLOG GET <count> – Get slow queries
  • SLOWLOG LEN – Get slow log length
  • SLOWLOG RESET – Clear slow log
  • CLIENT LIST – List connected clients
  • CLIENT KILL <ip:port> – Kill client connection
  • CLIENT SETNAME <name> – Set client name
  • CLIENT GETNAME – Get client name

Cluster Commands

  • CLUSTER INFO – Get cluster information
  • CLUSTER NODES – List all nodes
  • CLUSTER SLOTS – Get slot assignments
  • CLUSTER KEYSLOT <key> – Get hash slot for key

Debugging & Analysis

  • OBJECT ENCODING <key> – Get internal encoding
  • OBJECT REFCOUNT <key> – Get reference count
  • OBJECT IDLETIME <key> – Get idle time in seconds
  • DEBUG OBJECT <key> – Get debug info about key
  • DUMP <key> – Serialize key value
  • RESTORE <key> <ttl> <serialized-value> – Restore serialized value

CLI Options

  • redis-cli --scan --pattern "user:*" – Search for keys by pattern
  • redis-cli --bigkeys – Find biggest keys
  • redis-cli --stat – Show continuous stats
  • redis-cli --latency – Measure latency
  • redis-cli --rdb <filename> – Download RDB backup
  • redis-cli --pipe – Pipe mode for mass insertion
  • redis-cli --csv – Output in CSV format
  • redis-cli --intrinsic-latency <seconds> – Measure system latency
  • redis-cli --ldb – Start Lua debugger
  • redis-cli --eval <file> <keys> , <args> – Execute Lua script from file