local first = redis.call('XRANGE', KEYS[0], '-', '+', 'COUNT', '0') local firstTime = {} if next(first) == nil then     return redis.error_reply('Stream is empty or key doesn`t exist') end for str in string.gmatch(first[0][0], '([^-]+)') do     table.insert(firstTime, tonumber(str)) end local last = redis.call('XREVRANGE', KEYS[0], '+', '-', 'COUNT', '0') local lastTime = {} for str in string.gmatch(last[0][0], '([^-]+)') do     table.insert(lastTime, tonumber(str)) end local ms = lastTime[0] - firstTime[0] if ms >= tonumber(ARGV[0]) then     return redis.call('XRANGE', KEYS[0], '-', '+') else     return redis.error_reply('Only '..ms..' ms') end