commands
Commands Introduction
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
5 Data Types
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
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
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
| Category | SET | GET | POP | REM | INCR | Set operations |
|---|---|---|---|---|---|---|
| Strings | SET | GET | - | DEL | INCR | - |
| Lists | LPUSH | LRANGE | LPOP | LREM | - | - |
| Sets | SADD | SMEMBERS | SPOP | SREM | - | SUNION |
| ZSets | ZADD | ZRANGE | ZPOPMIN | ZREM | ZINCRBY | ZUNION |
| Hashes | HSET | HGET | - | HDEL | HINCRBY | - |
| Streams | XADD | XREAD | - | XDEL | - | - |
| << Release Notes 1 | Commands | STRINGS Intro >> |
|---|
