3/24/25, 12:08 AM Redis Commands Cheat sheet
Connect
CLI RedisInsight node-redis redis-py NRedisStack Jedis
# Syntax
redis-cli -u redis://host:port
redis-cli -u redis://username:password@host:port
# Examples
redis-cli
redis-cli -u redis://localhost:6379
redis-cli -u redis://myuser:mypassword@localhost:6379
# If you run Redis through Docker
docker exec -it <container-id-or-name> redis-cli
NOTE
To setup Redis either locally or in the cloud, refer to the tutorial
Strings/Numbers
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example Output
SET key
SET SET myKey "Hello" "OK"
value
https://redis.io/learn/howtos/quick-start/cheat-sheet 2/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Description: Set key to hold the string value. If key already holds a value, it is
overwritten, regardless of its type.Time Complexity: O(1)
GET GET key GET myKey "Hello"
Description: Get the string value of key. If the key does not exist the special value nil
is returned.Time Complexity: O(1)
MGET key 1) "Hello" 2)
MGET MGET myKey nonExistentKey
[key ...] (nil)
Description: Returns the values of all specified keys. For every key that does not hold
a string value or does not exist, the special value nil is returned.Time Complexity: O(N)
INCR INCR key INCR myCounter (integer) 1
Description: Increments the number stored at key by one. If the key does not exist, it
is set to 0 before performing the operation.Time Complexity: O(1)
Generic
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example Output
https://redis.io/learn/howtos/quick-start/cheat-sheet 3/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
KEYS
KEYS KEYS my* 1) "myKey" 2) "myCount
pattern
Description: Returns all keys matching pattern.Time Complexity: O(N)
EXISTS
EXISTS key [key EXISTS myKey (integer) 1
...]
Description: Checks if one or more keys exist.Time Complexity: O(N)
EXPIRE
EXPIRE key EXPIRE myKey 120 (integer) 1
seconds
Description: Set a timeout on a key.After the timeout has expired, the key will automatic
deleted.Time Complexity:O(1)
TTL TTL key TTL myKey (integer) 113
Description: Returns the remaining time to live of a key that has a timeout.Time Complex
PERSIST
PERSIST PERSIST myKey (integer) 1
key
Description: Removes the expiration from a key.Time Complexity:O(1)
https://redis.io/learn/howtos/quick-start/cheat-sheet 4/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
SCAN
cursor
[MATCH 1) "3" 2) 1) "myCounter"
SCAN SCAN 0 MATCH my* COUNT 2
pattern] "myKey"
[COUNT
count]
Description: Iterates the set of keys in the currently selected Redis database.Time
Complexity: O(1) for every call. O(N) for a complete iteration.
DEL key
DEL DEL myKey (integer) 1
[key ...]
Description: Removes the specified keys.Time Complexity: O(N)
# Server
redis_version:6.2.5
redis_git_sha1:0000000
redis_build_id:9893b2a
redis_mode:standalone
INFO INFO server
INFO os:Linux 5.4.72-microsof
[section] INFO keyspace
standard-WSL2 x86_64
arch_bits:64
...
# Keyspace
db0:keys=2,expires=0,a
Description:Returns information and statistics about the server, with the different sectio
server, clients, memory, persistence, stats, replication, cpu, commandstats, latencystats
sentinel, cluster, modules, keyspace, errorstats.Time Complexity: O(1)
https://redis.io/learn/howtos/quick-start/cheat-sheet 5/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Hashes
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example
HSET
key
field
HSET HSET h_employee_profile:101 name "Nicol" age 33
value
[field
value ...]
Description: Sets the specified fields to their respective values in the hash stored at key
Complexity: O(N)
HGET
HGET key HGET h_employee_profile:101 name
field
Description: Returns the value associated with field in the hash stored at key.Time Comp
HGETALL
HGETALL HGETALL h_employee_profile:101
key
Description: Returns all fields and values of the hash stored at key.Time Complexity: O(N)
https://redis.io/learn/howtos/quick-start/cheat-sheet 6/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
HMGET
key
HMGET HMGET h_employee_profile:101 name age
field1
[field2]
Description: Returns the values associated with the specified fields in the hash stored a
Complexity: O(N)
Sets
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example Ou
SADD key
(int
SADD member SADD mySet "Hello"
1
[member ...]
Description: Adds the specified members to the set stored at key. Time Complexity: O(N)
SMEMBERS
SMEMBERS SMEMBERS mySet 1) "H
key
Description: Returns all the members of the set value stored at key.Time Complexity: O(N
(int
SCARD SCARD key SCARD mySet
1
https://redis.io/learn/howtos/quick-start/cheat-sheet 7/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Description: Returns the set cardinality (number of elements) of the set stored at key.Ti
Complexity: O(1)
SISMEMBER
(int
SISMEMBER key SISMEMBER mySet "Hello"
1
member
Description: Returns if member is a member of the set stored at key.Time Complexity: O(1
SDIFF key1
SDIFF SDIFF mySet myOtherSet 1) "H
[key2]
Description: Returns the members of the set resulting from the difference between the
set and all the successive sets.Time Complexity: O(N)
SDIFFSTORE
(int
SDIFFSTORE destination SDIFFSTORE myNewSet mySet myOtherSet
1
key1 [key2]
Description: This command is equal to SDIFF, but instead of returning the resulting set, it
stored in destination.Time Complexity: O(N)
SREM key
(int
SREM member SREM mySet "Hello"
1
[member ...]
Description: Removes the specified members from the set stored at key.
Sorted sets
https://redis.io/learn/howtos/quick-start/cheat-sheet 8/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example Output
ZADD key score
(integer)
ZADD member [score ZADD myZSet 1 "one" 2 "two"
2
member ...]
Description: Adds all the specified members with the specified scores to the sorted
set stored at key. Time Complexity: O(log(N))
ZRANGE key
1) "one"
ZRANGE start stop ZRANGE myZSet 0 -1
2)"two"
[WITHSCORES]
Description: Returns the specified range of elements in the sorted set stored at
key.Time Complexity: O(log(N)+M) where M is the number of elements returned
Lists
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example Output
LPUSH key
LPUSH LPUSH myList "World" (integer) 1
value [value ...]
https://redis.io/learn/howtos/quick-start/cheat-sheet 9/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Description: Inserts the specified values at the head of the list stored at key. Time
Complexity: O(N)
RPUSH key
RPUSH RPUSH myList "Hello" (integer) 2
value [value ...]
Description: Inserts the specified values at the tail of the list stored at key.Time
Complexity: O(N)
LRANGE key 1) "World" 2)
LRANGE LRANGE myList 0 -1
start stop "Hello"
Description: Returns the specified elements of the list stored at key.Time
Complexity: O(S+N) where S is the distance of start and N is the number of elements in
the specified range.
LLEN LLEN key LLEN myList (integer) 2
Description: Returns the length of the list stored at key.Time Complexity: O(1)
LPOP key
LPOP LPOP myList "World"
[count]
Description: Removes and returns the first element of the list stored at key.Time
Complexity: O(N)
RPOP key
RPOP RPOP myList "Hello"
[count]
https://redis.io/learn/howtos/quick-start/cheat-sheet 10/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Description: Removes and returns the last element of the list stored at key.Time
Complexity: O(N)
Streams
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example
XADD key
field value
XADD XADD myStream * sensorId "1234" temperature
[field value
...]
Description: Appends the specified stream entry to the stream at the specified key. Tim
a new entry.
XREAD
[COUNT
count]
[BLOCK
XREAD XREAD COUNT 2 STREAMS myStream 0
milliseconds]
STREAMS
key [key ...]
ID [ID ...]
Description: Read data from one or multiple streams, only returning entries with an ID gre
reported by the caller.
https://redis.io/learn/howtos/quick-start/cheat-sheet 11/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
XRANGE key
start end
XRANGE XRANGE myStream 1518951480106-0 15189514801
[COUNT
count]
Description: Returns the entries matching a range of IDs in a stream. Time Complexity: O(
elements being returned. If N is constant (e.g. always asking for the first 10 elements wit
O(1).
XLEN XLEN key XLEN myStream
Description: Returns the number of entries of a stream. Time Complexity: O(1)
XDEL key ID
XDEL XDEL myStream 1518951480106-0
[ID ...]
Description: Removes the specified entries from a stream. Time Complexity: O(1) for each
stream
XTRIM key
XTRIM MAXLEN [~] XTRIM myStream MAXLEN 0
count
Description: Trims the stream to a different length. Time Complexity: O(N), with N being t
Constant times are very small however, since entries are organized in macro nodes conta
be released with a single deallocation.
https://redis.io/learn/howtos/quick-start/cheat-sheet 12/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
REDIS STACK COMMANDS
Redis stack extends the core features of Redis OSS like querying across hashes
and JSON documents, time series data support, full-text search ..etc
JSON
CLI node-redis redis-py NRedisStack Jedis
Command Syntax Example
JSON.SET key
JSON.SET JSON.SET employee_profile:1 . '{"n
path value
Description: Sets JSON value at path in key.Time Complexity: O(M+N) where M is the origi
JSON.GET key
JSON.GET JSON.GET employee_profile:1
[path [path ...]]
Description: Returns the JSON value at path in key.Time Complexity: O(N) when path is ev
is evaluated to multiple values, where N is the size of the key
JSON.NUMINCRBY JSON.SET employee_profile:1 .age 3
JSON.NUMINCRBY
key path number JSON.NUMINCRBY employee_profile:1
Description: Increments a number inside a JSON document.Time Complexity: O(1) when p
values, where N is the size of the key
https://redis.io/learn/howtos/quick-start/cheat-sheet 13/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
JSON.OBJKEYS
JSON.OBJKEYS JSON.OBJKEYS employee_profile:1
key [path]
Description: Return the keys in the object that's referenced by path. Time Complexity: O
keys in the object, O(N) when path is evaluated to multiple values, where N is the size of
JSON.OBJLEN
JSON.OBJLEN JSON.OBJLEN employee_profile:1
key [path]
Description: Report the number of keys in the JSON object at path in key. Time Complexi
evaluated to multiple values, where N is the size of the key
JSON.ARRAPPEND JSON.SET employee_profile:1 .color
JSON.ARRAPPEND key [path] value JSON.ARRAPPEND employee_profile:1
[value ...]
Description: Append the json values into the array at path after the last element in it. Tim
where N is the size of the key
JSON.ARRINSERT
JSON.ARRINSERT key path index JSON.ARRINSERT employee_profile:1
value [value ...]
Description: Insert the json values into the array at path before the index (shifts to the r
where N is the size of the array, O(N) when path is evaluated to multiple values, where N i
JSON.ARRINDEX
JSON.ARRINDEX key path value JSON.ARRINDEX employee_profile:1 .
[start [stop]]
https://redis.io/learn/howtos/quick-start/cheat-sheet 14/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Description: Searches for the first occurrence of a JSON value in an array. Time Complex
array, O(N) when path is evaluated to multiple values, where N is the size of the key
Search and Query
CLI node-redis redis-py NRedisStack Jedis
Command Syntax
FT.CREATE index
[ON HASH | JSON]
[PREFIX count prefix [prefix ...]]
[FILTER {filter}]
FT.CREATE SCHEMA
field_name [AS alias] TEXT | TAG | NUMERIC | GEO |
[NOINDEX]
...
Description: Create an index with the given specification.Time Complexity: O(K) where K
FT.SEARCH
FT.SEARCH index query
[FILTER numeric_field min max [ FILTER numeric_fie
[RETURN count identifier [AS property] [ identifie
[SORTBY sortby [ ASC | DESC] [WITHCOUNT]]
[LIMIT offset num]
[PARAMS nargs name value [ name value ...]]
https://redis.io/learn/howtos/quick-start/cheat-sheet 15/19
3/24/25, 12:08 AM Redis Commands Cheat sheet
Description: Search the index with a query, returning either documents or just ids. Time
FT.AGGREGATE index query
[LOAD count field [field ...]]
[ GROUPBY nargs property [property ...] [ REDUCE f
[ SORTBY nargs [ property ASC | DESC [ property AS
FT.AGGREGATE [ APPLY expression AS name ...
[ LIMIT offset num]
[FILTER filter]
[ PARAMS nargs name value [ name value ...]]
Description: Run a search query on an index, and perform aggregate transformations on
FT.INFO FT.INFO index
Description: Return information and statistics on the index.Time Complexity: O(1)
FT.DROPINDEX FT.DROPINDEX index [DD]
Description: Dropping existing index.Time Complexity:O(1) or O(N) if documents are delet
Join Redis University
https://redis.io/learn/howtos/quick-start/cheat-sheet 16/19