UNPKG

fume-fhir-converter

Version:

FHIR-Utilized Mapping Engine - Community

43 lines 1.32 kB
"use strict"; /** * © Copyright Outburn Ltd. 2022-2024 All Rights Reserved * Project name: FUME-COMMUNITY */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getCache = exports.initCache = void 0; const simpleCache_1 = require("./simpleCache"); /** Global app cache instance */ let appCache; const cacheKeys = [ 'tables', 'aliases', 'v2keyMap', 'expressions', 'compiledExpressions', 'mappings', 'compiledMappings', 'elementDefinition', 'definitions' ]; function initCache(options = {}) { // use map reduce to create caches with the right types. // if options are empty, all will be created SimpleCache. // options can override the type of cache and add options to it. appCache = cacheKeys.map((key) => { const CacheClass = options[key]?.cacheClass || simpleCache_1.SimpleCache; const cacheClassOptions = options[key]?.cacheClassOptions || {}; return new CacheClass(cacheClassOptions); }).reduce((acc, cache, index) => { acc[cacheKeys[index]] = cache; return acc; }, {}); } exports.initCache = initCache; function getCache() { if (!appCache) { throw new Error('Cache not initialized'); } return appCache; } exports.getCache = getCache; //# sourceMappingURL=cache.js.map