Существует пакет npm, который позволяет кэшировать топор ios GET-вызовы Redis. После просмотра документов я не могу передать его в кэш Redis. Я использую рекомендованную версию топора ios 0.18.1
, но все равно не радуюсь. Чего мне не хватает?
// Set-up code
const Axios = require('axios');
const Cache = require('axios-cache-adapter');
const Redis = require('redis');
const redis = Redis.createClient(); // using localhost
const redisStore = new Cache.RedisStore(redis);
const cacheMe = Cache.setupCache({
maxAge: 30 * 60 * 1000,
store: redisStore,
exclude: {
query: false
},
debug: true
});
const axios = Axios.create({
cache: cacheMe.adapter
});
// Snippet of axios call fromCache is always undefined
async resolve(root) {
const url = solrApi.getReports({ id: root.id });
const resp = await axios.get(url);
console.log(`Found ${ resp.data.response.numFound } record(s) in ${ resp.data.responseHeader.QTime } ms (fromCache: ${ resp.request.fromCache }`);
return resp.data.response.docs;
}