-
Notifications
You must be signed in to change notification settings - Fork 517
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
Implement ability to directly prime the cache #18
Conversation
the cache with a given key and value.
Looks like this build is failing right now just due to the babel-eslint/escope issue: babel/babel-eslint#243 (fixed in newest babel-eslint). |
Here's a PR to upgrade the babel-eslint dependency: #19 |
Friendly bump -- any thoughts on this PR? |
Sorry for the delay on this. Last time we discussed this we were concerned about the race-condition case where a current request is already outbound when I think the uses of building a two-index cache and pre-warming a cache are in some ways at odds with each other. Maybe the right way is to do nothing if they key already exists? That way you would have to explicitly declare if you wanted to forcefully prime the cache with |
Apologies for the delay on my end this time. Thanks for the feedback -- that makes sense, and your suggestion sounds great to me. I've updated the PR to reflect the new logic (priming an existing key will do nothing), and updated the documentation and tests to match. Thanks! |
Excellent work! |
This PR implements a new
prime(key, value)
API that directly primes the cache with a given key and value.This is mentioned in #2 as a way to enable building a two-way cache, but I think a more basic motivation for this API would simply be to allow cache pre-warming. Another use case I have for this is to allow creating a DataLoader subclass that implements
loadAll()
(https://gist.github.com/ryanspradlin/1e951a4dcf737e3fb194).