Skip to main content

ZRANDMEMBER

Note

Official reference: ZRANDMEMBER.

Read random members, optionally with scores.

Syntax

ZRANDMEMBER key [count [WITHSCORES]]

Omit count for one member; positive counts return distinct members and negative counts allow repeats. WITHSCORES must follow count.

Results

ReturnRowsContent
ResultSetmultipleELEMENT field, STRING type
SCORE field, DOUBLE type (when using WITHSCORES)

Example

ZADD demo:ranking 10 alice 20 bob
ZRANDMEMBER demo:ranking 2 WITHSCORES