Result freshening: Report Wikidata entities retrieved from memcached, add request flag getFreshResult
Report the Wikidata entities retrieved from memcached (T433455)
Every execution now reports the Wikidata entities it read from memcached, under the cachedWikidataEntities metadata key.
ReferenceResolver keeps the identifiers in a Set, and recording stops at 1000 distinct entities, as a security/performance measure.
cachedWikidataEntities is registered as an accumulating metadata key, so that when the evaluator starts returning the entities its callbacks read from cache, the existing merge in WFImplementation will fold them in with no further orchestrator work.
Also: Reordered the two Q431 blocks in memcachedTests.js (see commit for details).
Add request parameter getFreshResult, to run a call without cached Wikidata content (T433459)
With getFreshResult:true in the request body, the Wikidata entities that request needs are then fetched rather than read from memcached. The flag affects only the Wikidata path. It doesn't affect fetchZIDs, because cached ZIDs are kept current (see routes/persist-to-cache.js).
The write-back is deliberately left on. A fresh fetch replaces the entity it declined to read, so one busting request refreshes that entry for every request behind it. Also, due to our local caching, with getFreshResult:true there will only be one fetch per entity.
Important notes:
- It's fine to go ahead and merge and deploy this MR. It won't have any effect until WikiLambda starts passing
getFreshResult.cachedWikidataEntitieswill start to be returned, but it will be ignored by WikiLambda for now. - Cache-busting does not yet apply to callbacks; that's coming in several separate MRs (1 each for function-schemata, function-evaluator, function-orchestrator).
- Busting memoization caches will also be done later (if needed; let's discuss)