InMemoryCache and shouldReadFromCache (apollo-server-plugin-response-cache) #5271
-
Hello! I have a question about InMemoryCache. I am using the
So when this method returns false - we make a new request with the same arguments. Is it means that the previous cached request will be deleted from the cache? In continuation of my question - Is it possible to return the key of cached response and get access to methods of Best regards! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This means literally what it says: should the operation read from the cache or not? If it returns false, it never talks to the cache at all (no deletion or anything). You could use this to implement an HTTP request header that means "read a fresh value always", for example.
It sounds like you want to add extra logic around talking to the cache. One option is that you could implement the small |
Beta Was this translation helpful? Give feedback.
This means literally what it says: should the operation read from the cache or not? If it returns false, it never talks to the cache at all (no deletion or anything). You could use this to implement an HTTP request header that means "read a fresh value always", for example.
GraphQLRequestContext
has acache
on it, but you don't have access to the cache key inshouldReadFromCache
. (Part of the idea is to not take the performance hit of calculating the key in this case.)It sounds like you want to add extra logic around talking to the cache. One option is that you could implement the small
KeyValueCache
interface yourself, wrapping and delegating to a real cache. Then if you want yourget
t…