Type String
1. Memory storage model
2. Common operation commands
The command | instructions |
---|---|
set | Set a key/value |
get | Obtain the corresponding value based on the key |
mset | Set multiple keys and values at a time |
mget | Get multiple key values at once |
getset | Gets the value of the original key and sets the new value |
strlen | Get the length of the value stored by the corresponding key |
append | Appends the value of the corresponding key |
Getrange index 0 starts | Intercepts the contents of value |
setex | Set the lifetime of a key in seconds |
psetex | Set the lifetime of a key in milliseconds |
setnx | Exists No operation is performed, and no addition is performed |
Msetnx atom operation (as long as there is one does nothing) | Multiple keys can be set at the same time |
decr | Performs a -1 operation of numeric type |
decrby | Perform subtraction operations based on the data provided |
incr | Perform a +1 operation of numeric type |
incrby | Add based on the supplied data |
incrbyfloat | Add floating point numbers based on supplied data |
List the type
List A list is equivalent to a list set in Java. It is ordered and repeatable
Memory storage model
Common operation instruction
The command | instructions |
---|---|
lpush | Adds a value to the head of a key list |
lpushx | Same as push, but you have to make sure that this key exists |
rpush | Adds a value to the end of a key list |
rpushx | Same as Rpush, but you have to make sure that this key exists |
lpop | Returns and removes the first element on the left of the list |
rpop | Returns and removes the first element to the right of the list |
lrange | Getting the elements in one of the following table ranges can be used for paging |
llen | Gets the number of list elements |
lset | Sets the value of a specified index (so it must exist) |
lindex | Gets the element at a specified index position |
lrem | Delete duplicate elements |
ltrim | Keep elements within a specific range of the list |
linsert | Inserts a new element before or after an element |
The Set type
Characteristic: disorder cannot repeat
Memory storage model
Common commands
The command | instructions |
---|---|
sadd | Add elements to the collection |
smembers | Displays all elements in the collection out of order |
scard | Returns the number of elements in the collection |
spop | Returns a random element and deletes it from the collection |
smove | Moving elements from one collection to another must be of the same type |
srem | Removes an element from the collection |
sismember | Determines whether a collection contains this element |
srandmember | Random return element |
sdiff | Remove the same elements from the first set in other sets |
sinter | masked |
sunion | For collection |
ZSet type
Features: sortable set set, sorting is not repeatable
Memory storage model
Common commands
The command | instructions |
---|---|
zadd | Add an ordered collection element |
zcard | Returns the number of elements in the collection |
Zrange ascending Zrevrange descending | Returns a range of elements |
zrangebyscore | Find elements in a range by score |
zrank | Return to top |
zrevrank | List in reverse chronological order |
zscore | Displays the score of an element |
zrem | Remove an element |
zincrby | Give credit to a particular element |
Hash type
Features: Value is a map structure with keys and values, but keys are unordered
Memory storage model
Common commands
The command | instructions |
---|---|
hset | Set a key/value |
hget | Get a value for a key |
hgetall | Get all key/value pairs |
hdel | Example Delete a key or value |
hexists | Check whether a key exists |
hkeys | Get all the keys |
hvals | Get all values |
hmset | Set multiple keys and values |
hmget | Get multiple keys/values |
hsetnx | Set the value of a key that does not exist |
hincrby | Value must be of numeric type |
hincrbyfloat | Adds a floating point value to value |