阿波罗基本范例
https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Implementing-your-own-cache-backend
他们指出,执行redis缓存非常简单:
const { RedisCache } = require('apollo-server-cache-redis');
const server = new ApolloServer({
typeDefs,
resolvers,
cache: new RedisCache({
host: 'redis-server',
// Options are passed through to the Redis client
}),
dataSources: () => ({
moviesAPI: new MoviesAPI(),
}),
});
当我看到非Redis的例子时,它指出它是一个简单的
{ get, set }
用于缓存。这意味着理论上我应该能够做到。
cache : {
get : function() {
console.log("GET!");
},
set : function() {
console.log("SET!");
}
}
无论我尝试什么,当我使用Apollo服务器本机提供的graphql资源管理器时,都不会调用缓存函数。
我试过了
cacheControl : true
与
cacheControl
像它在里面一样设置
https://medium.com/brikl-engineering/serverless-graphql-cached-in-redis-with-apollo-server-2-0-f491695cac7f
. 没有什么。
有没有一个例子说明如何在Apollo中实现不使用付费Apollo引擎系统的基本缓存?