From cf669551f69edd66913d22c96cf1de1302e7990e Mon Sep 17 00:00:00 2001
From: Jacob Vosmaer <contact@jacobvosmaer.nl>
Date: Thu, 7 Apr 2016 15:42:07 +0200
Subject: [PATCH] Put CACHE_NAMESPACE in the Gitlab::Redis module

---
 config/application.rb | 4 +---
 lib/gitlab/redis.rb   | 2 ++
 lib/tasks/cache.rake  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/config/application.rb b/config/application.rb
index 9633084d603..2e2ed48db07 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -7,8 +7,6 @@ Bundler.require(:default, Rails.env)
 require_relative '../lib/gitlab/redis'
 
 module Gitlab
-  REDIS_CACHE_NAMESPACE = 'cache:gitlab'
-
   class Application < Rails::Application
     # Settings in config/environments/* take precedence over those specified here.
     # Application configuration should go into files in config/initializers
@@ -70,7 +68,7 @@ module Gitlab
     end
 
     redis_config_hash = Gitlab::Redis.redis_store_options
-    redis_config_hash[:namespace] = REDIS_CACHE_NAMESPACE
+    redis_config_hash[:namespace] = Gitlab::Redis::CACHE_NAMESPACE
     redis_config_hash[:expires_in] = 2.weeks # Cache should not grow forever
     config.cache_store = :redis_store, redis_config_hash
 
diff --git a/lib/gitlab/redis.rb b/lib/gitlab/redis.rb
index 8c3aea2627c..319447669dc 100644
--- a/lib/gitlab/redis.rb
+++ b/lib/gitlab/redis.rb
@@ -1,5 +1,7 @@
 module Gitlab
   class Redis
+    CACHE_NAMESPACE = 'cache:gitlab'
+
     attr_reader :url
 
     # To be thread-safe we must be careful when writing the class instance
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake
index 6c2e2e91494..2214f855200 100644
--- a/lib/tasks/cache.rake
+++ b/lib/tasks/cache.rake
@@ -9,7 +9,7 @@ namespace :cache do
       loop do
         cursor, keys = redis.scan(
           cursor,
-          match: "#{Gitlab::REDIS_CACHE_NAMESPACE}*", 
+          match: "#{Gitlab::Redis::CACHE_NAMESPACE}*", 
           count: CLEAR_BATCH_SIZE
         )
   
-- 
GitLab