// (C) 2021-2025 GoodData Corporation
import { LRUCache } from "lru-cache";
import { LOADER_CACHE_SIZE } from "./constants.js";
export const dataLoaderAbstractFactory = (createLoader) => {
    const loaders = new LRUCache({ max: LOADER_CACHE_SIZE });
    return {
        forWorkspace(workspace) {
            let loader = loaders.get(workspace);
            if (!loader) {
                loader = createLoader(workspace);
                loaders.set(workspace, loader);
            }
            return loader;
        },
        reset() {
            loaders.clear();
        },
    };
};
//# sourceMappingURL=DataLoaderAbstractFactory.js.map