I want to setup a script that sums up a bunch of values in a list and then puts down the result in
total-count and then removes the entire list, And this all should be repeated once a minute or as soon as the script completes. Is it possible to make a script that does this?
closed as unclear what you're asking by Mark Storey-Smith, Paul White, RolandoMySQLDBA, Michael - sqlbot, Kin Feb 20 at 14:30
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.
Redis doesn't do scheduling of jobs/scripts - you'll have to use something (e.g. cron) to trigger the script.
The script itself sounds simple enough - LRANGE should be used to iterate the list's elements, sum them up, SET
What bothers me, however, is that LRANGE would be O(N) and you want to run this all the time... that means your Redis will be busy doing this and all that just for an aggregate? Perhaps you should consider an alternative that will save all the work (from Redis) and the need to schedule a script. One possible alternative, for example, would be to add the list's members directly to the