diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /lib/gitlab/redis | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'lib/gitlab/redis')
-rw-r--r-- | lib/gitlab/redis/cache.rb | 19 | ||||
-rw-r--r-- | lib/gitlab/redis/cluster_shared_state.rb (renamed from lib/gitlab/redis/cluster_cache.rb) | 4 | ||||
-rw-r--r-- | lib/gitlab/redis/etag_cache.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/redis/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/redis/repository_cache.rb | 1 |
5 files changed, 31 insertions, 16 deletions
diff --git a/lib/gitlab/redis/cache.rb b/lib/gitlab/redis/cache.rb index 60944268f91..d63905cd896 100644 --- a/lib/gitlab/redis/cache.rb +++ b/lib/gitlab/redis/cache.rb @@ -8,9 +8,14 @@ module Gitlab class << self # Full list of options: # https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new + # pool argument event not documented in the link above is handled by RedisCacheStore see: + # https://github.com/rails/rails/blob/593893c901f87b4ed205751f72df41519b4d2da3/activesupport/lib/active_support/cache/redis_cache_store.rb#L165 + # and + # https://github.com/rails/rails/blob/ad790cb2f6bc724a89e4266b505b3c57d5089dae/activesupport/lib/active_support/cache.rb#L206 def active_support_config { redis: pool, + pool: false, compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), namespace: CACHE_NAMESPACE, expires_in: default_ttl_seconds @@ -20,20 +25,6 @@ module Gitlab def default_ttl_seconds ENV.fetch('GITLAB_RAILS_CACHE_DEFAULT_TTL_SECONDS', 8.hours).to_i end - - # Exposes redis for Peek adapter. To be removed after ClusterCache migration. - def multistore_redis - redis - end - - private - - def redis - primary_store = ::Redis.new(Gitlab::Redis::ClusterCache.params) - secondary_store = ::Redis.new(params) - - MultiStore.new(primary_store, secondary_store, store_name) - end end end end diff --git a/lib/gitlab/redis/cluster_cache.rb b/lib/gitlab/redis/cluster_shared_state.rb index 15a87739c6d..678566a0c9c 100644 --- a/lib/gitlab/redis/cluster_cache.rb +++ b/lib/gitlab/redis/cluster_shared_state.rb @@ -2,10 +2,10 @@ module Gitlab module Redis - class ClusterCache < ::Gitlab::Redis::Wrapper + class ClusterSharedState < ::Gitlab::Redis::Wrapper class << self def config_fallback - Cache + SharedState end end end diff --git a/lib/gitlab/redis/etag_cache.rb b/lib/gitlab/redis/etag_cache.rb new file mode 100644 index 00000000000..6aafdc8e518 --- /dev/null +++ b/lib/gitlab/redis/etag_cache.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Gitlab + module Redis + class EtagCache < ::Gitlab::Redis::Wrapper + class << self + def store_name + 'Cache' + end + + private + + def redis + primary_store = ::Redis.new(Gitlab::Redis::Cache.params) + secondary_store = ::Redis.new(Gitlab::Redis::SharedState.params) + + MultiStore.new(primary_store, secondary_store, name.demodulize) + end + end + end + end +end diff --git a/lib/gitlab/redis/feature_flag.rb b/lib/gitlab/redis/feature_flag.rb index 441ff669035..395805792d7 100644 --- a/lib/gitlab/redis/feature_flag.rb +++ b/lib/gitlab/redis/feature_flag.rb @@ -14,6 +14,7 @@ module Gitlab def cache_store @cache_store ||= FeatureFlagStore.new( redis: pool, + pool: false, compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), namespace: Cache::CACHE_NAMESPACE, expires_in: 1.hour diff --git a/lib/gitlab/redis/repository_cache.rb b/lib/gitlab/redis/repository_cache.rb index 966c6584aa5..6d0c35a6829 100644 --- a/lib/gitlab/redis/repository_cache.rb +++ b/lib/gitlab/redis/repository_cache.rb @@ -15,6 +15,7 @@ module Gitlab def cache_store @cache_store ||= RepositoryCacheStore.new( redis: pool, + pool: false, compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')), namespace: Cache::CACHE_NAMESPACE, expires_in: Cache.default_ttl_seconds |