Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. local result = redis.call('zrange', KEYS[1], 0, -1, 'withscores')
  2.  
  3. local count = 0
  4. local sum = 0
  5. local min = 0
  6. local max = 0
  7.  
  8. for i=1, #result, 2 do
  9. local score = result[i + 1]
  10.  
  11. count = count + 1
  12. sum = sum + score
  13.  
  14. if i == 1 then
  15. min = score
  16. max = score
  17. else
  18. min = math.min(min, score)
  19. max = math.max(max, score)
  20. end
  21. end
  22.  
  23. return {
  24. count, sum, min, max
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement