Skip to main content

ZCARD

Syntax​

ZCARD key

Module​

sortedset

Categories​

read slow sortedset

Description​

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​

Get the cardinality of the sorted set:

db, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
cardinality, err := db.ZCard("key")