对于列表,我可以执行以下操作:
LLEN KeyName
它将返回Redis列表的大小。对于集合,等效命令是什么?我似乎在任何文档中都找不到这个。
ZCOUNT myset -inf +inf
或者
ZCARD myset
zCard
is short for cardinality (cardinality is the number of elements in a set). It gives you total number of members inside of a "sorted set".
Sometimes you might wanna extract how many members are inside of a range in a sorted set. For that you can use zCount
.
ZCOUNT cars 0 50 // inclusive
这将包括0和55。0 ≤...≤ 50。但是如果您不想包括它们
ZCOUNT cars (0 (50
if it is regular set
SCARD cars