Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isFresh() {
let expires = this.params.expires;
let lastRun = this.lastRun;
return this.value &&
lastRun &&
expires &&
expires !== "immediately" &&
(expires === "never" || ago(expires).isBefore(lastRun));
}
constructor(strategyClass) {
this.strategyClass = strategyClass;
this.cache = new Cache();
}
resetCache() {
this.coordinator = new Coordinator(this);
}
query(store, type, params) {
let query = this.cache.getRecordArrayQuery(type, params);
if (!query) {
let strategy = new this.strategyClass();
query = new ArrayQuery(store, type, params, strategy);
this.cache.putRecordArrayQuery(query);
}
return query;
}
}
_getStorefrontBoxedQuery(type, url, params) {
let payload;
let fastboot = this.get('fastboot');
let isFastboot = fastboot && fastboot.get('isFastBoot');
let shoebox = fastboot && fastboot.get('shoebox');
let box = shoebox && shoebox.retrieve('ember-data-storefront');
if (!isFastboot && box && box.queries && Object.keys(box.queries).length > 0) {
let key = shoeboxize(cacheKey([type, url.replace(/^.*\/\/[^\/]+/, ''), params]));
payload = box.queries[key];
delete box.queries[key];
}
return payload;
}