Skip to main content

HRANDFIELD

Syntax​

HRANDFIELD key [count [WITHVALUES]]

Module​

hash

Categories​

hash read slow

Description​

Returns one or more random fields from the hash.

Options​

  • WITHVALUES - When provided, the return value will contain the field and its value. Otherwise, only the field is returned.

Examples​

Returns one or more random fields from the hash:

db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
fields, err := db.HRandField("key", db.HRandFieldOptions{})