isQueuePausedOrMaxed.lua 484 B

123456789101112131415161718
  1. --[[
  2. Function to check if queue is paused or maxed
  3. (since an empty list and !EXISTS are not really the same).
  4. ]]
  5. local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
  6. local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
  7. if queueAttributes[1] then
  8. return true
  9. else
  10. if queueAttributes[2] then
  11. local activeCount = rcall("LLEN", activeKey)
  12. return activeCount >= tonumber(queueAttributes[2])
  13. end
  14. end
  15. return false
  16. end