Commit 0fdee391 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'move-rails-cache-options-to-redis-cache' into 'master'

Move Rails cache options to Gitlab::Redis::Cache

See merge request gitlab-org/gitlab!71389
parents 05c74552 3b10a8eb
...@@ -372,15 +372,7 @@ module Gitlab ...@@ -372,15 +372,7 @@ module Gitlab
end end
# Use caching across all environments # Use caching across all environments
# Full list of options: config.cache_store = :redis_cache_store, Gitlab::Redis::Cache.active_support_config
# https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new
caching_config_hash = {}
caching_config_hash[:redis] = Gitlab::Redis::Cache.pool
caching_config_hash[:compress] = Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1'))
caching_config_hash[:namespace] = Gitlab::Redis::Cache::CACHE_NAMESPACE
caching_config_hash[:expires_in] = 2.weeks # Cache should not grow forever
config.cache_store = :redis_cache_store, caching_config_hash
config.active_job.queue_adapter = :sidekiq config.active_job.queue_adapter = :sidekiq
......
...@@ -4,6 +4,17 @@ module Gitlab ...@@ -4,6 +4,17 @@ module Gitlab
module Redis module Redis
class Cache < ::Gitlab::Redis::Wrapper class Cache < ::Gitlab::Redis::Wrapper
CACHE_NAMESPACE = 'cache:gitlab' 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment