Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
export function keyForCache(query) {
/*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/
// we want to ignore size, page, responsePath, and pageFilter in the cacheKey
const { size, page, responsePath, pageFilter, ...queryForCache } = query;
const cacheKeyObject = Object.keys(queryForCache)
.sort()
.reduce((result, key) => {
result[key] = queryForCache[key];
return result;
}, {});
return JSON.stringify(cacheKeyObject);
}
export default Store.extend({
// this is a map of map that stores the caches
lazyCaches: computed(function() {
return new Map();
}),
setLazyCacheForModel(modelName, key, value) {
const cacheKey = keyForCache(key);
const cache = this.lazyCacheForModel(modelName) || new Map();
cache.set(cacheKey, value);
const lazyCaches = this.lazyCaches;
const modelKey = normalizeModelName(modelName);
lazyCaches.set(modelKey, cache);
},
getLazyCacheForModel(modelName, key) {
const cacheKey = keyForCache(key);