Sha256: 52c56463b09f85eee49f105200b19ed3f2950ceb720a6ca8398fa7553b989c4d

Contents?: true

Size: 990 Bytes

Versions: 30

Compression:

Stored size: 990 Bytes

Contents

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

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
scrivito_sdk-1.18.0 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.18.0.rc1 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.17.0 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.17.0.rc3 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.17.0.rc2 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.17.0.rc1 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.16.0 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.16.0.rc2 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.16.0.rc1 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.15.0 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.15.0.rc2 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.15.0.rc1 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.14.0 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.14.0.rc3 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.14.0.rc2 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.14.0.rc1 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.13.0 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.13.0.rc2 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.13.0.rc1 app/cms/scrivito/backend/obj_load.rb
scrivito_sdk-1.12.0 app/cms/scrivito/backend/obj_load.rb