Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected throughTreeCache(name: string, category: string, fn: () => Tree | undefined): Tree | undefined {
let cacheKey;
if (typeof this.addonInstance.cacheKeyForTree === 'function') {
cacheKey = this.addonInstance.cacheKeyForTree(name);
if (cacheKey) {
cacheKey = cacheKey + category;
let cachedTree = this.app.addonTreeCache.get(cacheKey);
if (cachedTree) {
debug('cache hit %s %s %s', this.name, name, category);
return cachedTree;
}
}
}
debug('cache miss %s %s %s', this.name, name, category);
let tree = fn();
if (tree && cacheKey) {
this.app.addonTreeCache.set(cacheKey, tree);
}
return tree;
}
protected throughTreeCache(name: string, category: string, fn: () => Tree | undefined): Tree | undefined {
let cacheKey;
if (typeof this.addonInstance.cacheKeyForTree === 'function') {
cacheKey = this.addonInstance.cacheKeyForTree(name);
if (cacheKey) {
cacheKey = cacheKey + category;
let cachedTree = this.app.addonTreeCache.get(cacheKey);
if (cachedTree) {
debug('cache hit %s %s %s', this.name, name, category);
return cachedTree;
}
}
}
debug('cache miss %s %s %s', this.name, name, category);
let tree = fn();
if (tree && cacheKey) {
this.app.addonTreeCache.set(cacheKey, tree);
}
return tree;
}