Method: IdentityCache::Cached::PrimaryIndex#fetch_multi

Defined in:
lib/identity_cache/cached/primary_index.rb

#fetch_multi(ids) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/identity_cache/cached/primary_index.rb', line 34

def fetch_multi(ids)
  ids.map! { |id| cast_id(id) }.compact!
  id_to_record_hash = if model.should_use_cache?
    id_to_record_hash = CacheKeyLoader.load_multi(self, ids)
  else
    load_multi_from_db(ids)
  end
  records = ids.map { |id| id_to_record_hash[id] }
  records.compact!
  records
end