moving-sum.pl
Provides a simple example for managing "moving-sum" calculations with Redis:
total value tracked in one key
sorted sets used to record elements
total is incremented as new values are added
as old values drop out of the desired window, the total is decremented accordingly
The tracked total uses "incrbyfloat" in Net::Async::Redis::Commands to provide an atomic update when the new values are added and removed. This can be tracked using keyspace notifications, or simply polled if the update interval is low enough.
To install Net::Async::Redis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Async::Redis
CPAN shell
perl -MCPAN -e shell install Net::Async::Redis
For more information on module installation, please visit the detailed CPAN module installation guide.