Redis Sorted Sets: ZCARD
Redis ZCARD Command
Redis ZCARD command is used to return the number of elements stored in the set at specified key.
Here are some common uses and scenarios for the "ZCARD" command:
- Size Retrieval: Determine the cardinality (number of elements) of a sorted set.
- Data Validation: Validate the presence and size of sorted sets for consistency and correctness.
- Capacity Monitoring: Monitor the size of sorted sets to manage memory and performance.
- Conditional Logic: Execute operations based on the size of a sorted set.
- Resource Management: Manage resources by tracking the size of sorted sets for optimization.
Syntax:
ZCARD KEY_NAME
Available since
1.2.0.
Return Value
Integer replies the cardinality (number of elements) of the sorted set, or 0 if the key does not exist.
Return Value Type
Integer
Example: Redis ZCARD
127.0.0.1:6379> ZADD mycolorset 10 white 12 black 14 red 16 blue (integer) 4 127.0.0.1:6379> ZADD mycolorset 18 green 20 orange 22 pink 24 yellow (integer) 4 127.0.0.1:6379> ZCARD mycolorset (integer) 8 127.0.0.1:6379>
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-zcard-key.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics