getJobsInZset.lua 477 B

12345678910111213
  1. --[[
  2. We use ZRANGEBYSCORE to make the case where we're deleting a limited number
  3. of items in a sorted set only run a single iteration. If we simply used
  4. ZRANGE, we may take a long time traversing through jobs that are within the
  5. grace period.
  6. ]]
  7. local function getJobsInZset(zsetKey, rangeEnd, limit)
  8. if limit > 0 then
  9. return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd, "LIMIT", 0, limit)
  10. else
  11. return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd)
  12. end
  13. end