Aggregation Windows
Building and freeing up aggregation windows
Store module key-value storage can hold at most 1 GiB. It is usually enough if used correctly, but it is still a good idea (and sometimes even necessary) to free up unused keys. It is especially true for cases where you work with aggregation windows.
Consider this store module that aggregates hourly trade counter for each token:
Let's break it down.
First, we use Clock
input source to get the current and previous hour id for the block.
Then we build hourly keys for our counters and use add_many
method to increment them. These counters will be consumed downstream by other modules.
Here's the trick. Since we don't need these counters outside of the hourly window, we can safely delete these key-value pairs for the previous hourly window and free up the memory.
This is done using delete_prefix
method:
Links
Last updated