Cache database-redis data types and operations (set)

Source: Internet
Author: User

One: Redis collection (set)

Redis's set is an unordered collection of type string. A collection member is unique, which means that duplicate data cannot appear in the collection.

The collection in Redis is implemented by a hash table, so the complexity of adding, deleting, and finding is O (1).

Two: Set common operations

1) add element to Sadd (name,values) name corresponding collection

2) SCard (name) gets the number of elements in the collection for name

3) Sdiff (keys, *args) The collection of elements in the first name corresponding collection and not in the other name corresponding collection

4) Sdiffstore (dest, keys, *args) Gets the collection that corresponds to the first name and is not in the other name, and then adds it to the dest corresponding collection

5) Sinter (keys, *args) gets the set of one more name corresponding to the set

6) Sinterstore (dest, keys, *args) gets the set of one more name corresponding to the set, and then adds it to the corresponding collection of dest

7) Sismember (name, value) checks if value is a member of the collection that corresponds to name

8) smembers (name) gets all the members of the collection that the name corresponds to

9) smove (SRC, DST, value) move a member from one collection to another collection

Spop (name) removes a member from the right (tail) of the collection and returns it

One) srandmember (name, numbers) randomly gets numbers elements from the collection corresponding to name

Srem (name, values) removes certain values from the collection that corresponds to name

Sunion (keys, *args) gets the set of one more name corresponding to the collection

Sunionstore (Dest,keys, *args) gets the set of one more name corresponding to the collection and saves the result to the corresponding collection of dest

Sscan (name, cursor=0, Match=none, Count=none)

  

Cache database-redis data types and operations (set)

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.