Redis is an open-source, in-memory data structure store that is often used as a database, cache, and message broker. It supports a wide range of commands that allow users to interact with the data stored in Redis. Here’s a list of some common Redis commands along with their descriptions:

1. SET key value [EX seconds] [PX milliseconds] [NX|XX]

Description: Set the string value of a key.

Example:

SET mykey "Hello, Redis!"

2. GET key

Description: Get the value of a key.

Example:

GET mykey

3. DEL key [key …]

Description: Delete one or more keys.

Example:

DEL key1 key2 key3

4. EXISTS key

Description: Check if a key exists.

Example:

EXISTS mykey

5. KEYS pattern

Description: Find all keys matching the given pattern.

Example:

KEYS user*

6. INCR key

Description: Increment the integer value of a key by one.

Example:

SET counter 10  
INCR counter

7. DECR key

Description: Decrement the integer value of a key by one.

SET counter 10 
DECR counter

8. INCRBY key increment

Description: Increment the integer value of a key by ‘increment’.

Example:

SET counter 10 
INCRBY counter 5

9. DECRBY key decrement

Description: Decrement the integer value of a key by ‘decrement’.

Example:

SET counter 10 
DECRBY counter 3

10. HSET key field value

Description: Set the field in the hash stored at ‘key’ to ‘value’.

Example:

HSET user:123 name "John Doe"

11. HGET key field

Description: Get the value of a field from the hash stored at ‘key’.

Example:

HGET user:123 name

12. HMSET key field value [field value …]

Description: Set multiple fields in a hash stored at ‘key’.

Example:

HMSET user:123 name "John Doe" age 30 email "[email protected]"

13. HMGET key field [field …]

Description: Get the values of one or more fields from the hash stored at ‘key’.

Example:

HMGET user:123 name age

14. HDEL key field [field …]

Description: Delete one or more fields from the hash stored at ‘key’.

Example:

HDEL user:123 email

15. LPUSH key value [value …]

Description: Insert one or more values at the head of the list stored at ‘key’.

Example:

LPUSH mylist "one"
LPUSH mylist "two" "three"

16. RPUSH key value [value …]

Description: Insert one or more values at the tail of the list stored at ‘key’.

Example:

RPUSH mylist "one"
RPUSH mylist "two" "three"

17. LPOP key

Description: Remove and get the first element of the list stored at ‘key’.

Example:

LPOP mylist

18. RPOP key

Description: Remove and get the last element of the list stored at ‘key’.

Example:

RPOP mylist

19. SADD key member [member …]

Description: Add one or more members to the set stored at ‘key’.

Example:

SADD myset "one"
SADD myset "two" "three"

20. SMEMBERS key

Description: Get all the members of the set stored at ‘key’.

Example:

SMEMBERS myset

21. SREM key member [member …]

Description: Remove one or more members from the set stored at ‘key’.

Example:

SREM myset "two"

22. ZADD key [NX|XX] [CH] [INCR] score member [score member …]

Description: Add one or more members to a sorted set stored at ‘key’ with their scores.

Example:

ZADD mysortedset 90 "Alice" 85 "Bob" 95 "Carol"

23. ZRANGE key start stop [WITHSCORES]

Description: Get the elements with the lowest scores from the sorted set stored at ‘key’.

Example:

ZRANGE mysortedset 0 -1 WITHSCORES

24. ZREVRANGE key start stop [WITHSCORES]

Description: Get the elements with the highest scores from the sorted set stored at ‘key’.

Example:

ZREVRANGE mysortedset 0 -1 WITHSCORES

25. FLUSHALL

Description: Remove all keys from all databases in the current Redis instance.

Example:

FLUSHALL

References: For more commands and details refer Official Redis Documentation

By Abhishek K.

Author is a Architect by profession. This blog is to share his experience and give back to the community what he learned throughout his career.