diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 09:13:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 09:13:16 +0000 |
commit | ece36a21699c2a218b8bd14b22bea47d22218354 (patch) | |
tree | 8e08e12d70ead67a9b1f6951d29661463fda6387 /lib | |
parent | e168d3919a2c82eafa1d1f81e4b96aedae28717a (diff) | |
download | gitlab-ce-ece36a21699c2a218b8bd14b22bea47d22218354.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/environments.rb | 2 | ||||
-rw-r--r-- | lib/feature.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/redis.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/redis/feature_flag.rb | 25 |
4 files changed, 28 insertions, 2 deletions
diff --git a/lib/api/environments.rb b/lib/api/environments.rb index 0ce89e4240f..24339a1fe30 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -48,7 +48,7 @@ module API get ':id/environments' do authorize! :read_environment, user_project - if Feature.enabled?(:environment_search_api_min_chars, user_project) && params[:search].present? && params[:search].length < MIN_SEARCH_LENGTH + if params[:search].present? && params[:search].length < MIN_SEARCH_LENGTH bad_request!("Search query is less than #{MIN_SEARCH_LENGTH} characters") end diff --git a/lib/feature.rb b/lib/feature.rb index 94919edcce9..3847f880be0 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -326,7 +326,7 @@ module Feature end def l2_cache_backend - Rails.cache + ::Gitlab::Redis::FeatureFlag.cache_store end def log(key:, action:, **extra) diff --git a/lib/gitlab/redis.rb b/lib/gitlab/redis.rb index 4bc1d6c3989..64ca89c6bff 100644 --- a/lib/gitlab/redis.rb +++ b/lib/gitlab/redis.rb @@ -10,6 +10,7 @@ module Gitlab ALL_CLASSES = [ Gitlab::Redis::Cache, Gitlab::Redis::DbLoadBalancing, + Gitlab::Redis::FeatureFlag, Gitlab::Redis::Queues, Gitlab::Redis::RateLimiting, Gitlab::Redis::RepositoryCache, diff --git a/lib/gitlab/redis/feature_flag.rb b/lib/gitlab/redis/feature_flag.rb new file mode 100644 index 00000000000..441ff669035 --- /dev/null +++ b/lib/gitlab/redis/feature_flag.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Gitlab + module Redis + class FeatureFlag < ::Gitlab::Redis::Wrapper + FeatureFlagStore = Class.new(ActiveSupport::Cache::RedisCacheStore) + + class << self + # The data we store on FeatureFlag is currently stored on Cache. + def config_fallback + Cache + end + + def cache_store + @cache_store ||= FeatureFlagStore.new( + redis: pool, + compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), + namespace: Cache::CACHE_NAMESPACE, + expires_in: 1.hour + ) + end + end + end + end +end |