Class: Berater::StaticLimiter
- Defined in:
- lib/berater/static_limiter.rb
Constant Summary collapse
- LUA_SCRIPT =
Berater::LuaScript(<<~LUA local key = KEYS[1] local capacity = tonumber(ARGV[1]) local cost = tonumber(ARGV[2]) local count = redis.call('GET', key) or 0 local allowed = (count + cost) <= capacity if allowed then count = count + cost redis.call('SET', key, count) end return { tostring(count), allowed } LUA )
Constants inherited from Limiter
Instance Attribute Summary
Attributes inherited from Limiter
Instance Method Summary collapse
Methods inherited from Limiter
#==, cache_key, #limit, new, #redis, #utilization
Instance Method Details
#to_s ⇒ Object
44 45 46 |
# File 'lib/berater/static_limiter.rb', line 44 def to_s "#<#{self.class}(#{key}: #{capacity})>" end |