Skip to content

Instantly share code, notes, and snippets.

@stimms
Created August 13, 2014 20:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stimms/8ff3c43caf82ac3978a8 to your computer and use it in GitHub Desktop.
Save stimms/8ff3c43caf82ac3978a8 to your computer and use it in GitHub Desktop.
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