module SlavePools::QueryCache

duck-types with ActiveRecord::ConnectionAdapters::QueryCache but relies on ActiveRecord::Base.query_cache for state so we don't fragment the cache across multiple connections

we could use more of ActiveRecord's QueryCache if it only used accessors for its internal ivars.

Public Instance Methods

select_all(arel, name = nil, binds = []) click to toggle source

select_all is trickier. it needs to use the master connection for cache logic, but ultimately pass its query through to whatever connection is current.

# File lib/slave_pools/query_cache.rb, line 23
def select_all(arel, name = nil, binds = [])
  if query_cache_enabled && !locked?(arel)
    sql = to_sql(arel, binds)
    cache_sql(sql, binds) { route_to(current, :select_all, sql, name, binds) }
  else
    route_to(current, :select_all, arel, name, binds)
  end
end