Introduction
SRANDMEMBER helps you pick one or more random items from a set stored in Redis without removing them.
SRANDMEMBER key [count]
SRANDMEMBER myset
SRANDMEMBER myset 3SRANDMEMBER myset -2SADD fruits apple banana cherry date SRANDMEMBER fruits SRANDMEMBER fruits 2 SRANDMEMBER fruits -3
SRANDMEMBER do when used on a set?myset using SRANDMEMBER?SRANDMEMBER key [count], where count is optional and comes after the key.SRANDMEMBER myset 3 to get 3 random elements.colors containing {"red", "green", "blue"}, what could be the result of SRANDMEMBER colors 2?SRANDMEMBER myset -2 on a set with elements {"a", "b", "c"}, but get an error. What is the likely cause?players which contains only 3 unique names, allowing repeats. Which command correctly achieves this?-5 allows repeated elements in the result.Pass the test and this pattern moves unknown