Redis of NoSQL (under data type)
1.set Typ
(1) order
① adds elements
Syntax: SADD key member [member...]
② delete element
Syntax: SREM key member [member...]
③ gets all the elements in the collection
Syntax: SMEMBERS key
④ determines whether the element is in the collection
Syntax: SISMEMBER key member
(2) Operation commands of sets
① difference set
Syntax: SDIFF key [key...]
② intersection
Syntax: SINTER key [key...]
③ union
Syntax: SUNION key [key...]
(3) Enhancement order
① gets the number of elements in the collection
Syntax: SCARD key
② randomly pops an element from the collection
Syntax: SPOP key
2. Sortedset
(1) introduction: sortedset is an ordered set, which can be sorted, but the only difference between sortedset and set is that sortedset adds a score to the element, and then sorts it by score.
(2) order
① adds elements
Syntax: ZADD key score member [score member...]
② gets the score of the element
Syntax: ZSCORE key member
③ delete element
Syntax: ZREM key member [member...]
④ gets a list of elements ranked in a certain range
Note: all elements indexed from start to stop are returned in the order of element scores.
Syntax: ZRANGE key start stop [WITHSCORES]
Returns all elements indexed from start to stop in the order of element scores from high to low
Syntax: ZREVRANGE key start stop [WITHSCORES]
Rank elements and get scores
⑤ gets the ranking of elements:
From small to big:
Syntax: ZRANK key member
From big to small
Syntax: ZREVRANK key member
(2) Enhancement order
① gets the elements between the specified scores
Syntax: ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]
② increases the score of an element
Syntax: ZINCRBY key increment member
③ gets the number of elements in the collection
Syntax: ZCARD key
④ deletes elements according to the range of rankings
Syntax: ZREMRANGEBYRANK key start stop
⑤ deletes elements by score range