Commands Introduction

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

5 Data Types

Strings
key
value
Lists
key
value1, value2, ...
Sets
key
value1, value2, ...
Sorted Sets
key
value1, value2, ...
Hashes
key
value1, value2, ...

Redis has 5 data types. They can be grouped into String and the rest.
String has a one-to-one relationship between key and value; the others are one-to-many.


Strings

Here are two representative String commands.
SET is the typical command to store a value, and INCR increments the value by 1.
Click the incr button repeatedly to see the number increase.
Query command: GET key


Lists

List is used to store and process data in order.
LPUSH stores data in a list.   The first stored item is at the right end of the list, and the last stored item is at the left end.
RPOP pops data one by one from the right of the list.
Lists allow duplicate values.   Sets and Sorted Sets do not allow duplicates.
Query command: LRANGE key 0 -1


Sets

Set does not allow duplicate members. Even if you enter 'A' twice, only one remains.   Use Set for data with a set nature.
SADD is the command to store members.
Query command: SMEMBERS key


Sets intersection

A
B
C
B
C
D
myset1
myset2

Sets provide set operations. You can compute union, intersection, and difference.
Here we show intersection as a typical example.


Sorted Sets

Sorted Sets order members by score. As with Sets, duplicate members are not allowed.   Use Sorted Set when you need ordered data.
Query command: ZRANGE key 0 -1


Sorted Sets union

1
A
2
B
3
C
zip1
4
B
5
C
6
D
zip2

You can compute union and intersection, and operations using score are provided.


Hashes

Hash provides a field name so values can be distinguished by name.   It is similar to a table in an RDB.
HSET is the typical Hash store command.
HINCRBY increments by a specified number.
Query command: HGETALL key


Command summary

CategorySET GETPOP REMINCRSet operations
StringsSETGET- DELINCR-
ListsLPUSHLRANGELPOPLREM--
SetsSADDSMEMBERSSPOPSREM-SUNION
ZSetsZADDZRANGEZPOPMINZREMZINCRBYZUNION
HashesHSETHGET- HDELHINCRBY-
StreamsXADDXREAD- XDEL--

<< Release Notes 1 Commands STRINGS Intro >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.