getRateLimitTtl-2.lua 501 B

1234567891011121314151617181920212223242526
  1. --[[
  2. Get rate limit ttl
  3. Input:
  4. KEYS[1] 'limiter'
  5. KEYS[2] 'meta'
  6. ARGV[1] maxJobs
  7. ]]
  8. local rcall = redis.call
  9. -- Includes
  10. --- @include "includes/getRateLimitTTL"
  11. local rateLimiterKey = KEYS[1]
  12. if ARGV[1] ~= "0" then
  13. return getRateLimitTTL(tonumber(ARGV[1]), rateLimiterKey)
  14. else
  15. local rateLimitMax = rcall("HGET", KEYS[2], "max")
  16. if rateLimitMax then
  17. return getRateLimitTTL(tonumber(rateLimitMax), rateLimiterKey)
  18. end
  19. return rcall("PTTL", rateLimiterKey)
  20. end