-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cache): add support for surrogate cache key #6234
Conversation
Signed-off-by: Benjamin <[email protected]>
✅ Docs Preview ReadyNo new or changed pages found. |
@bnjjj, please consider creating a changeset entry in |
CI performance tests
|
at line 714 |
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
Context
Existing caching systems often support a concept of surrogate keys, where a key can be linked to a specific piece of cached data, independently of the actual cache key.
As an example, a news website might want to invalidate all cached articles linked to a specific company or person following an event. To that end, when returning the article, the service can add a surrogate key to the article response, and the cache would keep a map from surrogate keys to cache keys.
Surrogate keys and the router’s entity cache
To support a surrogate key system with the entity caching in the router, we make the following assumptions:
Router side support
The router has two features to support surrogate cache key:
subgraph_request_id
):apollo::entity_cache::cached_keys_status
, a mapsubgraph request id => cache keys
only when it's enabled in the configuration (expose_keys_in_context
)):The coprocessor will then work at two stages:
subgraph request id => cache keys
The coprocessor then has a map of
surrogate keys => cache keys
that it can use to invalidate cached data directly from Redis.Example workflow
Surrogate-Keys: homepage, feed
0e67db40-e98d-4ad7-bb60-2012fb5db504
:new
indicates newly cached data coming from the subgraph, linked to the surrogate keys, whilecached
is data obtained from the cache. These are the keys directly used in Redis:Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩