Add partial cache support to inject-links-pid #6
Loading…
Reference in a new issue
No description provided.
Delete branch "msz/query-rse-group:more-cache-and-tweaks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The
--record-cacheargument ininject_links_pidwas available but the cache was never used by the command. Given that this command normally requests records to be looked up from the Pool by class (not by single PID) it is not obvious what a full implementation of cache should look like (commands which fetch one PID at a time can consult cache first and API only if not cached).This PR adds partial, but hopefully intuitive cache handling. If the option
--only-from-cacheis given, then no requests to the API will be made; instead, all cached records (and cached records only) will be scanned, filtered by class name (if requested), checked whether they link the given object, and injected.No writing to cache is done. If the
--only-from-cacheoption is not used, the cache is ignored (as previously).This "inject from cache" was motivated by the following use case: extending Person records with their Project roles. This can be done as follows: Fetch project records, inline
associated_with::roles, save in cache, then run inject-links-pid --only-from-cache to inject projects with roles inlined (inline-records currently can't deal with nested properties).Note: This PR also bundled smaller tweaks in
pyproject.tomlwhich have since been cherry-picked by @mih (thanks!). I rebased & force-pushed the branch to get rid of (now empty) commits.8079dbd9feto16a7b74f8216a7b74f82tofb5b766334Add partial cache support toto Add partial cache support toinject-links-pid, small pyproject updateinject-links-pidI am finding this PR just now. No memory of having seen this before, but my own commit in www-from-model proves otherwise.
The --cache option in inject-links-pid appears to be unused still.
TBH, I do not like adding an option to interpret what the cache should be used for, whenever it is really just a choice between ONLY and NOTATALL. But the situation is messy to begin with, and the proposed solution certainly does not make it worse.
I need to add some tests, before I look more closely re a merge.
listininject-links-pid#9I am closing this PR, having filed #9
I think it is better to take a fresh look at the problem, now that a new set of tools became available.
Pull request closed