lib/scrivito/backend/obj_query.rb in scrivito_sdk-0.70.2 vs lib/scrivito/backend/obj_query.rb in scrivito_sdk-0.71.0.rc1

- old
+ new

@@ -8,11 +8,18 @@ cache = Backend::ObjDataCache.view_for_revision(revision) missing_keys = [] ids_from_cache = keys.map do |key| - result = cache.read_index(index.id, key, &index.method(:update)) + result = + if key == nil + # querys for `nil` are not supported since they kill performance. + # return empty list without asking the backend. + [] + else + cache.read_index(index.id, key, &index.method(:update)) + end missing_keys << key unless result result end @@ -51,10 +58,12 @@ end all_obj_datas = Backend::ObjLoad.load(revision, all_ids) nested_ids.map do |ids| - all_obj_datas.shift(ids.length) if ids + # use 'compact' to filter out any objs that are still referenced by id + # in the cache, but have been deleted in the backend concurrently. + all_obj_datas.shift(ids.length).compact if ids end end end end