Module: ActiveRecord::ConnectionAdapters::QueryCache

Defined in:
lib/rcache/query_cache.rb

Instance Method Summary collapse

Instance Method Details

#select_all(arel, name = nil, binds = []) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rcache/query_cache.rb', line 4

def select_all(arel, name = nil, binds = [])
  if (arel.rcache_value rescue false) && !locked?(arel) && (arel.rcache_value[:expires_in] || Rcache.expires_in).to_i > 0
    sql = to_sql(arel, binds)
    redis_cache_sql(arel.rcache_value, sql, binds) { super(sql, name, binds) }
      .collect { |row| row.dup }
  elsif @query_cache_enabled && !locked?(arel)
    sql = to_sql(arel, binds)
    cache_sql(sql, binds) { super(sql, name, binds) }
  else
    super
  end
end

#select_value(arel, name = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/rcache/query_cache.rb', line 17

def select_value(arel, name = nil)
  binds = []
  if (arel.rcache_value rescue false) && !locked?(arel) && (arel.rcache_value[:expires_in] || Rcache.expires_in).to_i > 0
    sql = to_sql(arel, binds)
    redis_cache_sql(arel.rcache_value, sql, binds) { super(sql, name) }
  else
    super
  end
end