UNPKG

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

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

41 lines (39 loc) 936 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataLoaderCache = void 0; 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 = this.createKey({ ...params, name: "" }); for (const current in this.cache) { if (current.startsWith(key) === false) { continue; } this.cache[current].clearAll(); } } createKey(params) { return `${params.tenant}_${params.locale}_${params.name}`; } } exports.DataLoaderCache = DataLoaderCache; //# sourceMappingURL=DataLoaderCache.js.map