local time = redis.call('TIME')
local now = time[1] * 1000 + math.floor(time[2] / 1000)
local limit = tonumber(ARGV[1])
local result = {tostring(now), tostring(redis.call('ZCARD', KEYS[1]))}
for keyIndex = 2, #KEYS do
local key = KEYS[keyIndex]
local due = redis.call('ZRANGEBYSCORE', key, '-inf', now, 'WITHSCORES', 'LIMIT', 0, limit)
local nextEntry = redis.call('ZRANGE', key, 0, 0, 'WITHSCORES')
result[#result + 1] = nextEntry[2] or ''
result[#result + 1] = tostring(#due / 2)
for index = 1, #due do
result[#result + 1] = due[index]
end
end
return result