代码拉取完成,页面将自动刷新
$ cargo build
Only tested in redis 5.x
$ redis-server --appendonly yes --loadmodule target/debug/libaggregate.dylib
$ redis-cli agg.new btc_usdt time price amount value
OK
$ redis-cli agg.view btc_usdt kline_1m interval 60 first price max price min price last price sum amount sum value
OK
$ redis-cli agg.insert btc_usdt `date +%s` 1001.11 1.0 `echo '1001.11 * 1.0' | bc`
OK
$ redis-cli agg.insert btc_usdt `date +%s` 1000.01 1.2 `echo '1000.01 * 1.2' | bc`
OK
$ redis-cli agg.save btc_usdt
OK
$ redis-cli hgetall kline_1m
3) "1563715680"
4) "[1001.11,1001.11,1000.01,1000.01,2.2,2201.12]"
What the above example does is basically select time_bucket('1 minute', time), first(price), max(price), min(price), last(price), sum(amount), sum(value) from btc_usdt group by 1
, but runs in realtime/incremental/streaming way.
interval n
option is like group by in sql, their results are written into hash value, whose key is timestamp for the time bucket. The aggregation view without interval
option, there results are written into simple string values.agg.save
get called.min
, max
, first
, last
, sum
, avg
.aof-use-rdb-preamble yes
, or just disable appendonly. It saves me some time to implement aof rewrite operation, i think this option will be the default in the future anyway.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型