Skip to content
Snippets Groups Projects
Commit cf669551 authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Put CACHE_NAMESPACE in the Gitlab::Redis module

parent 3137f61a
No related branches found
No related tags found
No related merge requests found
Loading
@@ -7,8 +7,6 @@ Bundler.require(:default, Rails.env)
Loading
@@ -7,8 +7,6 @@ Bundler.require(:default, Rails.env)
require_relative '../lib/gitlab/redis' require_relative '../lib/gitlab/redis'
   
module Gitlab module Gitlab
REDIS_CACHE_NAMESPACE = 'cache:gitlab'
class Application < Rails::Application class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
Loading
@@ -70,7 +68,7 @@ module Gitlab
Loading
@@ -70,7 +68,7 @@ module Gitlab
end end
   
redis_config_hash = Gitlab::Redis.redis_store_options 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 redis_config_hash[:expires_in] = 2.weeks # Cache should not grow forever
config.cache_store = :redis_store, redis_config_hash config.cache_store = :redis_store, redis_config_hash
   
Loading
Loading
module Gitlab module Gitlab
class Redis class Redis
CACHE_NAMESPACE = 'cache:gitlab'
attr_reader :url attr_reader :url
   
# To be thread-safe we must be careful when writing the class instance # To be thread-safe we must be careful when writing the class instance
Loading
Loading
Loading
@@ -9,7 +9,7 @@ namespace :cache do
Loading
@@ -9,7 +9,7 @@ namespace :cache do
loop do loop do
cursor, keys = redis.scan( cursor, keys = redis.scan(
cursor, cursor,
match: "#{Gitlab::REDIS_CACHE_NAMESPACE}*", match: "#{Gitlab::Redis::CACHE_NAMESPACE}*",
count: CLEAR_BATCH_SIZE count: CLEAR_BATCH_SIZE
) )
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment