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.