Cache data on the server with manually created caches #584
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.
This is a breakout from #570 and replaces
makeServerQueryCachein that PR. More background can be found there.Before this PR, queries wont ever get cached in a server environment to avoid leaking sensitive information between requests (#70). This PR makes it so any cache that has been manually created via
makeQueryCachewill cache data, even on the server.This change wont improve SSR (much) by itself but is a prerequisite. I'm pretty sure this PR is the only breaking change needed and that de/rehydration can be achieved without breaking changes.
This also adds some extra guards for
scheduleStaleandscheduleGarbage, since I don't believe these should ever be called on the server. Lifetime on the server should be manually managed (usually lifetime should be a single request).I saw
defaultConfigwas added tomakeQueryCache. I needed an extrafrozen-option that I don't think makes sense as a cache config, but rather an option tomakeQueryCacheitself, so I took the liberty of changing the signature into anoptions-object instead if that's ok?I'm not sure if the
frozen-option should be documented and public or not and it would also be trivial to add.freeze()and.unfreeze()-methods, but I'm not sure if I see any use-cases for exposing this?Just a heads up: I'm AFK for about a week from tomorrow, so while I can read and respond, actually fixing comments will take some time. 😄 I'll tackle next steps after that.