Sha256: f6ae94b78a9b34816ba7cba69c2613e3bfd646b66d4331cc506da9bc7e34c215

Contents?: true

Size: 736 Bytes

Versions: 5

Compression:

Stored size: 736 Bytes

Contents

# query cache methods are moved to ConnectionPool for Rails >= 5.0
module Octopus
  module ConnectionPool
    module QueryCacheForShards
      %i(enable_query_cache! disable_query_cache!).each do |method|
        define_method(method) do
          if(Octopus.enabled? && (shards = ActiveRecord::Base.connection.shards)['master'] == self)
            shards.each do |shard_name, v|
              if shard_name == 'master'
                super()
              else
                v.public_send(method)
              end
            end
          else
            super()
          end
        end
      end
    end
  end
end

ActiveRecord::ConnectionAdapters::ConnectionPool.send(:prepend, Octopus::ConnectionPool::QueryCacheForShards)

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ar-octopus-ruby-3-0.11.3 lib/octopus/query_cache_for_shards.rb
ar-octopus-ruby-3-0.11.2 lib/octopus/query_cache_for_shards.rb
ar-octopus-0.10.2 lib/octopus/query_cache_for_shards.rb
ar-octopus-0.10.1 lib/octopus/query_cache_for_shards.rb
ar-octopus-0.10.0 lib/octopus/query_cache_for_shards.rb