SCARD
This page documents the preview (v2.21) version. Preview includes features under active development and is for development and testing only. For production, use the stable (v2024.1) version.
Synopsis
s
This command finds the cardinality of the set that is associated with the given key. Cardinality is the number of elements in a set.
- If the
keydoes not exist, 0 is returned. - If the
keyis associated with a non-set value, an error is raised.
Return value
Returns the cardinality of the set.
Examples
You can do this as shown below.
$ SADD yuga_world "America"
1
$ SADD yuga_world "Asia"
1
$ SCARD yuga_world
2