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