summaryrefslogtreecommitdiff
path: root/lib/gitlab/redis/cache.rb
blob: a2c7b5e29dba680a644f6b087e5cf12f8fb8b74e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module Gitlab
  module Redis
    class Cache < ::Gitlab::Redis::Wrapper
      CACHE_NAMESPACE = 'cache:gitlab'

      # Full list of options:
      # https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new
      def self.active_support_config
        {
          redis: pool,
          compress: Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1')),
          namespace: CACHE_NAMESPACE,
          expires_in: 2.weeks # Cache should not grow forever
        }
      end
    end
  end
end