From 90fde5053d6309405d6ff6b5698fae7c871905cc Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 11 Mar 2016 17:25:24 +0800 Subject: [PATCH] FIX: Load Redis patch much earlier. --- config/application.rb | 1 + config/initializers/001-redis.rb | 15 --------------- lib/freedom_patches/redis.rb | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 lib/freedom_patches/redis.rb diff --git a/config/application.rb b/config/application.rb index 18e838f55a9..69a4531dd03 100644 --- a/config/application.rb +++ b/config/application.rb @@ -147,6 +147,7 @@ module Discourse require 'discourse_redis' require 'logster/redis_store' + require 'freedom_patches/redis' # Use redis for our cache config.cache_store = DiscourseRedis.new_redis_store $redis = DiscourseRedis.new diff --git a/config/initializers/001-redis.rb b/config/initializers/001-redis.rb index 0d1e2c6b038..73340cc49da 100644 --- a/config/initializers/001-redis.rb +++ b/config/initializers/001-redis.rb @@ -1,18 +1,3 @@ -# https://github.com/redis/redis-rb/pull/591 -class Redis - class Client - alias_method :old_initialize, :initialize - - def initialize(options = {}) - old_initialize(options) - - if options.include?(:connector) && options[:connector].is_a?(Class) - @connector = options[:connector].new(@options) - end - end - end -end - if Rails.env.development? && ENV['DISCOURSE_FLUSH_REDIS'] puts "Flushing redis (development mode)" $redis.flushall diff --git a/lib/freedom_patches/redis.rb b/lib/freedom_patches/redis.rb new file mode 100644 index 00000000000..8bab1e7141d --- /dev/null +++ b/lib/freedom_patches/redis.rb @@ -0,0 +1,14 @@ +# https://github.com/redis/redis-rb/pull/591 +class Redis + class Client + alias_method :old_initialize, :initialize + + def initialize(options = {}) + old_initialize(options) + + if options.include?(:connector) && options[:connector].is_a?(Class) + @connector = options[:connector].new(@options) + end + end + end +end