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!