Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

TOPK.COUNT

Last updated
TOPK.COUNT key item [item ...]
Group
Top-K
Complexity
O(n * depth), n being the items
Arity
-1 (at least 1 words, counting the command name)
Flags
none
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

TOPK.COUNT returns the estimated count of each item in the Top-K at key, whether or not the item is currently in the list. Estimates are approximate, especially for rare items; use TOPK.LIST WITHCOUNT for the counts of the listed items.

An array with one integer per item (0 for an item never seen), the same in RESP2 and RESP3.

Error replies: TopK: key does not exist, and WRONGTYPE if the key holds another type.

127.0.0.1:6379> TOPK.RESERVE trending 2 50 4 0.9
OK
127.0.0.1:6379> TOPK.INCRBY trending hotkv 10 redis 4
1) (nil)
2) (nil)
127.0.0.1:6379> TOPK.COUNT trending hotkv redis memcached
1) (integer) 10
2) (integer) 4
3) (integer) 0

Same as TOPK.COUNT in RedisBloom, where the command is deprecated in favor of TOPK.LIST WITHCOUNT. HotKV keeps it supported.

TOPK.LIST, TOPK.QUERY, TOPK.INCRBY