Skip to content

InMemoryCache and shouldReadFromCache (apollo-server-plugin-response-cache) #5271

Answered by glasser
DmitriiKholodov asked this question in Q&A
Discussion options

You must be logged in to vote

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 a cache on it, but you don't have access to the cache key in shouldReadFromCache. (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 your get t…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mmerezhko-hv
Comment options

@trevor-scheer
Comment options

@mmerezhko-hv
Comment options

Answer selected by DmitriiKholodov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants