lib/prop/limiter.rb in prop-2.2.0 vs lib/prop/limiter.rb in prop-2.2.1
- old
+ new
@@ -144,10 +144,13 @@
private
def _throttle(handle, key, cache_key, options)
return [false, @strategy.zero_counter] if disabled?
- counter = @strategy.change(cache_key, options)
+ amount = options.key?(:decrement) ?
+ -(options.fetch(:decrement)) :
+ options.fetch(:increment, 1)
+ counter = @strategy.change(cache_key, amount, options)
if @strategy.compare_threshold?(counter, :>, options)
before_throttle_callback &&
before_throttle_callback.call(handle, key, options[:threshold], options[:interval])