Created
August 13, 2014 20:34
-
-
Save stimms/8ff3c43caf82ac3978a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local currentval = redis.call('get', ARGV[1]) | |
local currentcount = redis.call('get', ARGV[1] .. '.count') | |
redis.call('incr', ARGV[1] .. '.count') | |
currentval = (currentval * (currentcount/(currentcount + 1))) + (ARGV[2]/(currentcount+1)) | |
redis.call('set', ARGV[1], currentval) | |
return currentval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment