2021-11-18 22:05:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Redis
|
|
|
|
class RateLimiting < ::Gitlab::Redis::Wrapper
|
2023-04-23 21:23:45 +05:30
|
|
|
class << self
|
|
|
|
# The data we store on RateLimiting used to be stored on Cache.
|
|
|
|
def config_fallback
|
|
|
|
Cache
|
|
|
|
end
|
|
|
|
|
|
|
|
def cache_store
|
|
|
|
@cache_store ||= ActiveSupport::Cache::RedisCacheStore.new(
|
|
|
|
redis: pool,
|
|
|
|
namespace: Cache::CACHE_NAMESPACE,
|
|
|
|
error_handler: ::Gitlab::Redis::ERROR_HANDLER
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def redis
|
|
|
|
primary_store = ::Redis.new(::Gitlab::Redis::ClusterRateLimiting.params)
|
|
|
|
secondary_store = ::Redis.new(params)
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
MultiStore.new(primary_store, secondary_store, name.demodulize)
|
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|