module ActiveRecordCache::FinderMethods

Protected Instance Methods

cached_lookup_allowed?() click to toggle source

only support the most basic lookups through the cache

# File lib/activerecord_cache/finder_methods.rb, line 33
def cached_lookup_allowed?
  @klass.use_activerecord_cache && arel.where_sql.nil? && arel.join_sources.empty? && @limit_value.nil? && @offset_value.nil?
end
find_one_with_caching(id) click to toggle source
# File lib/activerecord_cache/finder_methods.rb, line 22
def find_one_with_caching(id)
  return find_one_without_caching(id) unless cached_lookup_allowed?

  record = find_through_cache(id)

  raise_record_not_found_exception!(id, 0, 1) unless record

  record
end
find_some_with_caching(ids) click to toggle source
# File lib/activerecord_cache/finder_methods.rb, line 12
def find_some_with_caching(ids)
  return find_some_without_caching(ids) unless cached_lookup_allowed?

  results = find_some_through_cache(ids)

  raise_record_not_found_exception!(ids, results.size, ids.size) unless results.size == ids.size

  results
end