module Scrivito module Backend module ObjLoad def self.load(revision, ids) cache = Backend::ObjDataCache.view_for_revision(revision) missing_ids = [] results_from_cache = ids.map do |id| result = cache.read_obj(id) missing_ids << id unless result result end overall_results = if missing_ids.blank? results_from_cache else raw_results = revision.obj_mget_request(missing_ids) results_from_backend = raw_results.map do |result| ObjDataCache.convert_from_backend(result) end results_from_backend.each_with_index do |result, index| cache.write_obj(missing_ids[index], result) end results_from_cache.map do |result| result || results_from_backend.shift end end overall_results.map do |raw_data| if raw_data != ObjDataCache::NONEXISTENT_OBJ Backend::ObjDataFromRest.new(raw_data) end end end end end end