2022-08-13 15:12:31 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module ApplicationRateLimiter
|
|
|
|
class IncrementPerAction < BaseStrategy
|
|
|
|
def increment(cache_key, expiry)
|
|
|
|
with_redis do |redis|
|
2022-10-11 01:57:18 +05:30
|
|
|
redis.pipelined do |pipeline|
|
|
|
|
pipeline.incr(cache_key)
|
|
|
|
pipeline.expire(cache_key, expiry)
|
2022-08-13 15:12:31 +05:30
|
|
|
end.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def read(cache_key)
|
|
|
|
with_redis do |redis|
|
|
|
|
redis.get(cache_key).to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|