Redis Detailed--set collection operation

Source: Internet
Author: User

Commands for set operations
Sadd (Key, member): Adds an element to a set named Key member


Srem (Key, member): Removes the element in the set named Key member


Spop (key): Randomly returns and deletes an element in a set with the name key


Smove (Srckey, Dstkey, member): Moves the member element from a collection named Srckey to a collection named Dstkey


SCard (Key): Returns the cardinality of a set named key


Sismember (Key, member): Test whether the member is a set element with the name key


Sinter (Key1, Key2,... key N): Intersection


Sinterstore (Dstkey, Key1, Key2,... key N): Sets the intersection and saves the intersection to Dstkey


Sunion (Key1, Key2,... key N): Seek and set


Sunionstore (Dstkey, Key1, Key2,... key N): Set and save the set to Dstkey


Sdiff (Key1, Key2,... key N): Differential set


Sdiffstore (Dstkey, Key1, Key2,... key N): Differential set and save the difference set to Dstkey collection


Smembers (Key): Returns all elements of a set with the name key


Srandmember (key): Randomly returns an element of a set with the name key


Commands for Zset (sorted set) operations
Zadd (Key, Score,member): Adds an element member,score for sorting to a zset named key. If the element already exists, the order of the element is updated according to score.


Zrem (Key, member): Removes the element in Zset with the name Key member


Zincrby (key, Increment, member): If the element member already exists in the Zset with the name key, the score of the element is incremented increment; otherwise, the element is added to the collection and its score value is increment


Zrank (Key, member): Returns the rank (that is, index, starting from 0) of the member element in the Zset with the name key (the element has been sorted score from small to large), and returns "nil" if there are no member elements


Zrevrank (Key, member): Returns the rank (that is, index, starting from 0) of the member element in the Zset with the name key (the element has been sorted by score from large to small), and returns "nil" if there is no member element


Zrange (Key, Start,end): Returns all elements of index from start to end in Zset with the name key (the element has been sorted by score from small to large)


Zrevrange (Key, Start,end): Returns all elements of index from start to end in Zset with the name key (the element has been sorted by score from large to small)


Zrangebyscore (Key, Min, max): Returns all elements of score >= min and score<= max in Zset named key


Zcard (Key): Returns the cardinality of the Zset with the name key


Zscore (key, Element): Returns the score of element elements in Zset with the name key


Zremrangebyrank (Key, Min, max): Remove all elements of rank >= min and rank<= max in Zset named key


Zremrangebyscore (Key, Min, max): Removes all elements of score >=min and score <= Max in Zset named key


Zunionstore/zinterstore (Dstkeyn, Key1,..., KeyN, WEIGHTS W1,... wn,aggregatesum| min| MAX): Sets and intersections of N Zset, and saves the last collection in Dstkeyn. For the score of each element in a collection, multiply the weight parameter for the aggregate operation before doing it. If weight is not provided, the default is 1. The default aggregate is sum, that is, the score of the elements in the result set is the value of the sum operation for all the corresponding elements of the collection, while Min and Max means that the score of the elements in the result set are the minimum and maximum values in the corresponding elements of all the collections.

Redis Detailed--set collection operation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.