Detailed explanation of the use of five major data types in Redis

Article directory

stirng

Set string type data

set key value 

Get the value corresponding to the key

get key

Get the substring of the string corresponding to the key (start to end subscripts start from 0, if end is greater than the length, the last character is returned by default, end=-1 means the end is the last character)

getrange key start end

Get the value of multiple keys

mget key1 key2 key3 ...

Returns the length of the string corresponding to key

strlen key

Set multiple key-value pairs

mset key1 value1 key2 value2 ...

Add one to value (value must be a number, if not, return an error message)

incr key

add increment to value

inyrbr key increment

subtract one from value

decr key

Subtract a number from value

decrby key increment

String append (append to the end of the original string)

append key value (value为要追加的字符串)

hash

Create hash data

hmset key filed1 value1

Get all fields and values ​​in the specified hash table

hgetall key

Get the value of the specified field stored in the hash table

hget key filed

Delete one or more hash table fields

hdel key filed1 filed2 ...

Get the number of fields in a hash table

hlen key

Get all fields in hash table

hkeys key

Get all the values ​​in the hash table

hvals key

list

Insert elements at the head of the list (each element is placed at the front of the current, similar to the head insertion method)

lpush key value1 value2 ....

Insert elements at the end of the list (each element is placed at the end of the current, similar to tail insertion)

rpush key value1 value2 ...

get list length

llen key

Get the element with the specified subscript (subscript starts from 0)

lindex key index

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324199437&siteId=291194637