redis Set type command

Set in Redis is an unordered, non-duplicate collection data structure. It provides a series of operation commands for adding, deleting, and searching operations on Set. The following are some common commands of Set type in Redis:

  1. SADD key member [member …] : Adds one or more members to the specified collection.

    Example:SADD myset value1 value2 value3

  2. SCARD key : Get the number of members of the specified collection.

    Example:SCARD myset

  3. SMEMBERS key : Get all members of the specified collection.

    Example:SMEMBERS myset

  4. SISMEMBER key member : Determine whether the specified member exists in the set.

    Example:SISMEMBER myset value

  5. SREM key member [member …] : Remove one or more members from the set.

    Example:SREM myset value1 value3

  6. SPOP key : Randomly removes and returns a member of the set.

    Example:SPOP myset

  7. SRANDMEMBER key [count] : Randomly obtain one or more members in the set. Count can specify the number to be returned. If count is a positive number, non-duplicate members will be returned. If count is a negative number, duplicate members will be returned.

    Example:SRANDMEMBER myset 2

  8. SUNION key [key …] : Returns the union of all given sets.

    Example:SUNION set1 set2

  9. SDIFF key [key …] : Returns the difference of the first set relative to other sets.

    Example:SDIFF set1 set2

  10. SINTER key [key …] : Returns the intersection of the given sets.

    Example:SINTER set1 set2

Guess you like

Origin blog.csdn.net/drhnb/article/details/132177276