Class: Berater::StaticLimiter
- Defined in:
- lib/berater/static_limiter.rb
Constant Summary collapse
- LUA_SCRIPT =
Berater::LuaScript("local key = KEYS[1]\nlocal capacity = tonumber(ARGV[1])\nlocal cost = tonumber(ARGV[2])\n\nlocal count = redis.call('GET', key) or 0\nlocal allowed = (count + cost) <= capacity\n\nif allowed then\n count = count + cost\n redis.call('SET', key, count)\nend\n\nreturn { tostring(count), allowed }\n" )
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 |