HRANDFIELD
Syntax
HRANDFIELD key [count [WITHVALUES]]
Module
hashCategories
hash read slowDescription
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
- Go (Embedded)
- CLI
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{})
Returns one or more random fields from the hash:
> HRANDFIELD key