Redis Learning Note (12)--redis common operation instruction (iii)

Source: Internet
Author: User
Tags redis set set
Set set common operations directives

Set is a single-valued, multi-value data structure that does not allow the same elements to exist
Sadd key value [value]

Adding elements to form the association of key and value

Note that if we enter a value with duplicate content, Redis will automatically remove the weight and add it to the collection as shown below

Smembers Key

View collection elements

SCard Key

Gets the number of elements in the collection

Srem Key value

Removing elements from a collection

Srandmember key [Count]

Get multiple values randomly from the collection, without adding a number, by default randomly fetching a number, if the set number exceeds the number of data in the collection, then all out

Spop key [Count]

Random out stack, default random stack one number

Smove Key1 Key2 value1

Assign a value in Key1 to Key2
Here we move the 12 in the MySet to the myset01
Math Set Class Difference Set

Sdiff key1 Key2 [key 3]

Inside the first element and no longer behind any of the collections.
intersection

Sinter key1 Key2 [Key3]

and set

Sunion key1 Key2 [Key3]

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.