Module: Switchman::ActiveRecord::Core

Defined in:
lib/switchman/active_record/core.rb

Instance Method Summary collapse

Instance Method Details

#initialize_find_by_cacheObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/switchman/active_record/core.rb', line 6

def initialize_find_by_cache
  if ::Rails.version < '5'
    self.find_by_statement_cache = ShardAwareStatementCache.new(shard_category)
  else
    # note that this will not work beyond ActiveRecord 5.0.0.beta3 since
    #  as of beta4 this has been replaced with a hash containing two separate caches:
    #  one for prepared statements, and one for unprepared ones
    @find_by_statement_cache = ShardAwareStatementCache.new(shard_category)
  end
end