diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-29 13:38:21 +0400 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-29 13:38:21 +0400 |
commit | 185e7681d2357396f9d5fa70414d5597a78c9008 (patch) | |
tree | 943eaab4dc359034fc62d5f68c926489187818ef /config | |
parent | d4180875cbd361b0b3905fac08c94ff5931695a9 (diff) |
Move cache setup to config/application.rb
Before this change we were trying to configure Rails.cache in an
initializer. It seems that by the time the initializers are loaded,
Rails.cache is already instantiated, so changing the settings does not
achieve anything anymore. This was causing Rails to default to a file
storage cache instead of the Redis cache, which in turn broke `rake
cache:clear`.
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 19 | ||||
-rw-r--r-- | config/initializers/7_cache_settings.rb | 20 |
2 files changed, 19 insertions, 20 deletions
diff --git a/config/application.rb b/config/application.rb index 58a5949c653..68dce05fc59 100644 --- a/config/application.rb +++ b/config/application.rb @@ -73,5 +73,24 @@ module Gitlab resource '/api/*', headers: :any, methods: [:get, :post, :options, :put, :delete] end end + + # Use Redis caching across all environments + redis_config_file = Rails.root.join('config', 'resque.yml') + + redis_url_string = if File.exists?(redis_config_file) + YAML.load_file(redis_config_file)[Rails.env] + else + "redis://localhost:6379" + end + + # Redis::Store does not handle Unix sockets well, so let's do it for them + redis_config_hash = Redis::Store::Factory.extract_host_options_from_uri(redis_url_string) + redis_uri = URI.parse(redis_url_string) + if redis_uri.scheme == 'unix' + redis_config_hash[:path] = redis_uri.path + end + + redis_config_hash[:namespace] = 'cache:gitlab' + config.cache_store = :redis_store, redis_config_hash end end diff --git a/config/initializers/7_cache_settings.rb b/config/initializers/7_cache_settings.rb deleted file mode 100644 index 5367a4d431c..00000000000 --- a/config/initializers/7_cache_settings.rb +++ /dev/null @@ -1,20 +0,0 @@ -Gitlab::Application.configure do - redis_config_file = Rails.root.join('config', 'resque.yml') - - redis_url_string = if File.exists?(redis_config_file) - YAML.load_file(redis_config_file)[Rails.env] - else - "redis://localhost:6379" - end - - # Redis::Store does not handle Unix sockets well, so let's do it for them - redis_config_hash = Redis::Store::Factory.extract_host_options_from_uri(redis_url_string) - redis_uri = URI.parse(redis_url_string) - if redis_uri.scheme == 'unix' - redis_config_hash[:path] = redis_uri.path - end - - redis_config_hash[:namespace] = 'cache:gitlab' - - config.cache_store = :redis_store, redis_config_hash -end |