Hi!
Has anyone been able to use the shouldReadFromCache and shouldWriteToCache methods from the sample code (which btw works well)?
I am trying to remove some queries from being cached, otherwise it’s quite unusable to cache everything.
Thanks!
Hi!
Has anyone been able to use the shouldReadFromCache and shouldWriteToCache methods from the sample code (which btw works well)?
I am trying to remove some queries from being cached, otherwise it’s quite unusable to cache everything.
Thanks!
Yes!
Your query will be identified by the key: requestContext.operationName. Simply retrieve your query name and use a switch (or if statement) to return false when it matches.
Example:
Ex:
async function shouldReadFromCache(requestContext) {
switch (requestContext.operationName) {
case ‘GET_COMMENTS’:
return false
default:
return true
}
@Roy is it possible to clear the cache for a specific query instead of clearing everything?
meanwhile, here is a library that work out of the box.
10Life/strapi-plugin-advanced-cache-manager: A Cache Management for Strapi. (github.com)
@abisewski Yes, you can clear cache that having the max age as you defined in the configuration.
Does this still work Roy? Due to the deprecated deprecated apollo-server-caching? Deprecation Error: apollo-server-core and apollo-server-cache-redis · Issue #6 · 10Life/strapi-plugin-advanced-cache-manager · GitHub
Hey @Roy and @lozcozard, Im also looking into using Redis cache and thank you for putting together the library Roy! Just wondering about the same question as @lozcozard, will there be an update to use new libraries because of the deprecation?