getTargetQueueList.lua 812 B

12345678910111213141516171819202122
  1. --[[
  2. Function to check for the meta.paused key to decide if we are paused or not
  3. (since an empty list and !EXISTS are not really the same).
  4. ]]
  5. local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
  6. local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
  7. if queueAttributes[1] then
  8. return pausedKey, true, queueAttributes[3], queueAttributes[4]
  9. else
  10. if queueAttributes[2] then
  11. local activeCount = rcall("LLEN", activeKey)
  12. if activeCount >= tonumber(queueAttributes[2]) then
  13. return waitKey, true, queueAttributes[3], queueAttributes[4]
  14. else
  15. return waitKey, false, queueAttributes[3], queueAttributes[4]
  16. end
  17. end
  18. end
  19. return waitKey, false, queueAttributes[3], queueAttributes[4]
  20. end