Skip to main content

Redis Command Cheatsheet

Redis is an open-source, in-memory data structure store used as a database, cache, and message broker. This cheatsheet summarizes the most commonly used Redis commands, grouped by data type and function for quick reference.

Updated: 2026-07-17·35 commands

Overview

Redis (Remote Dictionary Server) is an in-memory data structure store used as a database, cache, and message broker. This cheatsheet covers the most commonly used Redis commands organized by data type.

Quick Start

``bash redis-cli ping # Test connection redis-cli # Enter interactive mode ``

Refer to the command table below for detailed usage.

Basic Ops(11)

CommandLevel
SET key value [NX|XX] [EX seconds] [PX milliseconds]
Set the value of a key, with optional NX (only if not exists), XX (only if exists), EX (seconds), PX (milliseconds)
Basic
GET key
Get the value of a key
Basic
DEL key [key ...]
Delete one or more keys
Basic
EXISTS key [key ...]
Check if one or more keys exist, returns the count of existing keys
Basic
TYPE key
Return the type of the value stored at a key
Basic
EXPIRE key seconds
Set a key time to live in seconds
Basic
TTL key
Get the remaining time to live of a key in seconds. -1 means no expiry, -2 means key does not exist
Basic
RENAME key newkey
Rename a key, overwrites the destination if it already exists
Intermediate
KEYS pattern
Find all keys matching the given pattern. WARNING: blocks Redis on large datasets in production
Expert
INFO [section]
Get information and statistics about the Redis server, optionally filtered by section (server, memory, stats)
Intermediate
FLUSHALL [ASYNC]
Delete all keys from all databases. Extremely dangerous in production; always back up first. Supports ASYNC mode
Expert

Strings(4)

CommandLevel
MSET key value [key value ...]
Set multiple key-value pairs atomically
Intermediate
MGET key [key ...]
Get the values of multiple keys atomically
Intermediate
INCR key
Increment the integer value of a key by one (atomic)
Basic
DECR key
Decrement the integer value of a key by one (atomic)
Basic

Lists(6)

CommandLevel
LPUSH key value [value ...]
Prepend one or more values to a list (left side)
Basic
RPUSH key value [value ...]
Append one or more values to a list (right side)
Basic
LPOP key
Remove and return the first element of a list (left side)
Basic
RPOP key
Remove and return the last element of a list (right side)
Basic
LLEN key
Get the length of a list
Basic
LRANGE key start stop
Get a range of elements from a list, inclusive of start and stop. Use negative numbers to count from the end
Basic

Sets(4)

CommandLevel
SADD key member [member ...]
Add one or more members to a set
Basic
SMEMBERS key
Return all members of a set
Basic
SINTER key [key ...]
Return the intersection of multiple sets
Intermediate
SUNION key [key ...]
Return the union of multiple sets
Intermediate

Hashes(4)

CommandLevel
HSET key field value [field value ...]
Set the value of a field in a hash. Overwrites if the field already exists
Basic
HGET key field
Get the value of a field in a hash
Basic
HGETALL key
Get all fields and values in a hash
Basic
HDEL key field [field ...]
Delete one or more fields from a hash
Basic

Sorted Sets(4)

CommandLevel
ZADD key score member [score member ...]
Add one or more members to a sorted set, or update the score of existing members
Intermediate
ZRANGE key start stop [WITHSCORES]
Return members of a sorted set by index range (ascending order by score)
Intermediate
ZREVRANGE key start stop [WITHSCORES]
Return members of a sorted set by index range (descending order by score)
Intermediate
ZRANK key member
Determine the index of a member in a sorted set (ascending order, 0-based)
Intermediate

Pub/Sub(2)

CommandLevel
PUBLISH channel message
Post a message to a channel
Intermediate
SUBSCRIBE channel [channel ...]
Subscribe to one or more channels to receive messages. Note: the client enters listening mode after subscribing
Intermediate

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-17.