ZCARD
Syntax
ZCARD key
Module
sortedsetCategories
read slow sortedsetDescription
Returns the set cardinality of the sorted set at key. If the key does not exist, 0 is returned, otherwise the cardinality of the sorted set is returned. If the key holds a value that is not a sorted set, this command will return an error.
Examples
- Go (Embedded)
- CLI
Get the cardinality of the sorted set:
db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
cardinality, err := db.ZCard("key")
Get the cardinality of the sorted set:
> ZCARD key