UNPKG

@webiny/api-headless-cms-ddb-es

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

31 lines (30 loc) 751 B
export class DataLoaderCache { cache = {}; getDataLoader(params) { const key = this.createKey(params); return this.cache[key] || null; } setDataLoader(params, dataLoader) { const key = this.createKey(params); this.cache[key] = dataLoader; } clearAll(params) { if (!params) { for (const current in this.cache) { this.cache[current].clearAll(); } return; } const key = `${params.tenant}_`; for (const current in this.cache) { if (current.startsWith(key) === false) { continue; } this.cache[current].clearAll(); } } createKey(params) { return `${params.tenant}_${params.modelId}_${params.name}`; } } //# sourceMappingURL=DataLoaderCache.js.map