Skip to main content

HRANDFIELD

Note

Official reference: HRANDFIELD.

Read random hash fields, optionally with their values.

Syntax​

HRANDFIELD key [count [WITHVALUES]]

Omit count for one field. Positive counts return distinct fields; negative counts allow repeats. WITHVALUES must follow count.

Results​

ReturnRowsContent
ResultSetmultipleFIELD field, STRING type
VALUE field, STRING type (when using WITHVALUES)

Example​

HSET demo:user name mali age 18
HRANDFIELD demo:user 2 WITHVALUES