debian-mirror-gitlab/lib/gitlab/application_rate_limiter/base_strategy.rb
2022-08-13 15:12:31 +05:30

24 lines
581 B
Ruby

# frozen_string_literal: true
module Gitlab
module ApplicationRateLimiter
class BaseStrategy
# Increment the rate limit count and return the new count value
def increment(cache_key, expiry)
raise NotImplementedError
end
# Return the rate limit count.
# Should be 0 if there is no data in the cache.
def read(cache_key)
raise NotImplementedError
end
private
def with_redis(&block)
::Gitlab::Redis::RateLimiting.with(&block) # rubocop: disable CodeReuse/ActiveRecord
end
end
end
end