(stub)
| 45 | |
| 46 | |
| 47 | def resolve(stub): |
| 48 | _instrument_stub(stub) |
| 49 | cache_keys = {} |
| 50 | schemata = {} |
| 51 | for clazz, key, schema in stub._rx_queue: |
| 52 | if (clazz, key) in stub._rx_cache: |
| 53 | continue |
| 54 | |
| 55 | cid = cache.object_key(clazz, key) |
| 56 | cache_keys[cid] = (clazz, key) |
| 57 | schemata[cid] = schema |
| 58 | |
| 59 | keys = list(cache_keys.keys()) |
| 60 | queries = defaultdict(list) |
| 61 | for cid, value in cache.get_many_complex(keys): |
| 62 | clazz, key = cache_keys.get(cid) |
| 63 | if value is None: |
| 64 | # log.info("MISS [%s]: %s", clazz.__name__, key) |
| 65 | if clazz == Entity: |
| 66 | queries[schemata.get(cid)].append(key) |
| 67 | loader = LOADERS.get(clazz) |
| 68 | if loader is not None: |
| 69 | value = loader(key) |
| 70 | stub._rx_cache[(clazz, key)] = value |
| 71 | |
| 72 | for schema, ids in queries.items(): |
| 73 | for entity in entities_by_ids(ids, schemata=schema, cached=True): |
| 74 | stub._rx_cache[(Entity, entity.get("id"))] = entity |
| 75 | |
| 76 | |
| 77 | def get(stub, clazz, key): |
no test coverage detected