我正在apollo服务器中使用apollo-server-caching,在突变请求上,缓存没有更新,并且在前端发生突变后重新查询时,我正在获取旧的缓存数据
任何人都可以指导我,如何处理阿波罗服务器中的突变缓存更新?
下面是我的服务器缓存代码实现
export class MemoryCache implements KeyValueCache {
cache: { [key: string]: string } = {};
async get(key: string): Promise<string> {
console.log(`get ${key}`);
const value = this.cache[key];
return value;
}
async set(key: string, value: string): Promise<void> {
console.log(`set ${key}`);
this.cache[key] = value;
}
async delete(key: string): Promise<void> {
console.log(`delete: ${key}`);
delete this.cache[key];
}
async reset() {
this.cache = {};
}
}