redis_srandmember()

Read(302) Label: set, random member,

Description:

  Get one or multiple random members from a set.

Syntax:

redis_srandmember(con,key[,count])

Note:

External library function. If parameter count isn’t supplied, return a random member from the set. When the parameret count is supplied: If the value of parameter count is positive and less than the number of the set, return an arrry containing unique members and whose length is count. If the value of count is equal to or greater than the number of the set, return the whole set. If the value of parameter count is negative, return an array that could contain duplicate members and whose length is the absolute value of the count.

Parameters:

con

Database connection string

key

Set name

count

The number of returned members; can be omitted.

Return value:

A table sequence

Example:

 

A

 

1

=redis("192.168.18.131:6379","runqian")

 

2

=redis_srandmember(A1,"fruit")

3

=redis_srandmember(A1,"fruit",2)

 

4

 

=redis_srandmember(A1,"fruit",3)

5

=redis_srandmember(A1,"fruit",10)

6

 

=redis_srandmember(A1,"fruit",-3)

7

=redis_srandmember(A1,"fruit",-5)