Repository navigation
Scope all caching to the KG client, and fix stale and incorrect cache entries - #167
Merged
Merged
Conversation
… entries The module-level caches fairgraph.caching.object_cache and save_cache are removed. They were shared by every client in the process, so in a web service objects retrieved with one user's token could be returned to another user, and they ignored the release status, kept unsaved changes after a rejected update, and kept the ids of deleted instances. The ids of instances found by, or created after, an existence query are now remembered by the client, and KGProxy.resolve() retrieves instances through the client's document cache, returning a new object each time (#80). The client's document cache now keeps the "in progress" and "released" documents of each instance separately, applies the require_full_data check after the cache lookup, and returns copies. A lookup with release_status="any" for an instance that has not been released is answered from the cache, but a direct lookup of the released document always asks the KG. The cache is now also cleared when an instance is released, unreleased or moved to another space, and deleting an instance removes it from the existence cache. store_query() now invalidates the cached query definition. Instances that also have an openMINDS URI, such as controlled terms, are cached once, under their KG URI, whichever URI they were retrieved with, so that they are found in the cache by either URI, and cleared from it when they are changed. KGQuery.resolve() now sets the release status of the objects it returns, so that resolving their own links uses the same release status, where it previously reverted to "released".
# Conflicts: # doc/release_notes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, fairgraph caches in four places: two caches in each
KGClient(JSON-LD documents, and stored query definitions), and two module-level caches,fairgraph.caching.object_cache(resolved objects) andsave_cache(the ids found by existence queries). The review in #80 found several problems with them:object_cacheignores it when resolving proxies, so "released" and "in progress" content are mixed up.save_cache.store_query()leaves the old definition cached.With this PR, all caching is done by the client:
KGProxy.resolve()retrieves instances through the client's document cache, and returns a new object each time.release_status="any"for an instance that hasn't been released is answered from the cache, but a direct lookup of the released document always asks the KG, so releases made by others are seen.It also fixes
KGQuery.resolve(), which doesn't currently set the release status of the objects it returns. Resolving their own links therefore reverts to "released", which matters more now that resolution respects the release status strictly.Changes in behaviour, listed in the release notes:
release_status="in progress"or"any". Previously,object_cacheoften returned it anyway. Withfollow_links, such links are left as proxies, with a warning.fairgraph.caching.object_cacheandsave_cacheno longer exist, andKGClient.cachehas a new layout.Limiting how long cache entries live, or how many there are, is left to #168. Caches now last as long as the client.
Fixes #80