getCountsPerPriority-4.lua 753 B

1234567891011121314151617181920212223242526272829303132333435
  1. --[[
  2. Get counts per provided states
  3. Input:
  4. KEYS[1] wait key
  5. KEYS[2] paused key
  6. KEYS[3] meta key
  7. KEYS[4] prioritized key
  8. ARGV[1...] priorities
  9. ]]
  10. local rcall = redis.call
  11. local results = {}
  12. local waitKey = KEYS[1]
  13. local pausedKey = KEYS[2]
  14. local prioritizedKey = KEYS[4]
  15. -- Includes
  16. --- @include "includes/isQueuePaused"
  17. for i = 1, #ARGV do
  18. local priority = tonumber(ARGV[i])
  19. if priority == 0 then
  20. if isQueuePaused(KEYS[3]) then
  21. results[#results+1] = rcall("LLEN", pausedKey)
  22. else
  23. results[#results+1] = rcall("LLEN", waitKey)
  24. end
  25. else
  26. results[#results+1] = rcall("ZCOUNT", prioritizedKey,
  27. priority * 0x100000000, (priority + 1) * 0x100000000 - 1)
  28. end
  29. end
  30. return results