Set Type and redisset type in redis

Source: Internet
Author: User

Set Type and redisset type in redis


In redis, the set type is an unordered Set. It is implemented through HashTable in redis. The advantage of the set data type is to quickly find whether an element exists and record some non-repeated values, for example, the user name cannot be the same during website registration.


Set has the following command:

1. sadd key member adds a string-type element to the set corresponding to the key.

2. scard key returns the number of set Elements

3. sismember key m1 determines whether the m1 element exists in the set in the key.

4. The smembers key returns all elements of the set corresponding to the key, and the result is unordered.




The set type is also very useful in the voting system. For example, if one user can only vote once in a day, we can use the date as a key every day and the user id as a member, to check whether a user is voting, you only need the sismember date user ID, which is very efficient!

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.