TOPK.RESERVE
Syntax
TOPK.RESERVE key topk [width depth decay]
Time complexity: O(1)
ACL categories: @topk
Creates a new Top-K data structure at key that tracks the top topk most frequent items.
topk: The number of top items to track (between1and100000).width(optional): The number of counters per hash function row (default8, max1000000).depth(optional): The number of hash function rows (default7, max100).decay(optional): The probability decay factor between0and1(default0.9).
The default parameters are recommended for most use cases.
In particular, the default decay value of 0.9 uses a globally shared pre-computed lookup table,
while a custom decay value forces Dragonfly to allocate a separate lookup table in memory for each key.
Using many Top-K structures with different custom decay values will result in higher memory consumption.
If width, depth, and decay are provided, all three must be specified together.
If key already exists, an error (item exists) is returned.
Return
Simple string reply: OK if the Top-K was created successfully.
An error is returned if:
- The
keyalready exists. - The parameters are out of the allowed ranges.
Examples
dragonfly> TOPK.RESERVE topk 3
OK
dragonfly> TOPK.RESERVE topk_custom 5 20 7 0.9
OK