From c0f95f971a9f4af5312518dbfe6d976f775f2e2b Mon Sep 17 00:00:00 2001 From: "Theo N. Truong" <644650+nhtruong@users.noreply.github.com> Date: Wed, 10 Sep 2025 16:46:54 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=84=EF=B8=8F=20refactor:=20Make=20`APP?= =?UTF-8?q?=5FCONFIG`=20a=20Dedicated=20Cache=20Store=20(#9558)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - This allows use APP_CONFIG in FORCED_IN_MEMORY_CACHE_NAMESPACES - Remove the complexity of nested namespace (e.g. we no longer have to worry about the prefix of every role key) --- api/cache/getLogStores.js | 1 + api/server/services/Config/app.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/cache/getLogStores.js b/api/cache/getLogStores.js index dfb2017448..e6714f55ec 100644 --- a/api/cache/getLogStores.js +++ b/api/cache/getLogStores.js @@ -31,6 +31,7 @@ const namespaces = { [CacheKeys.SAML_SESSION]: sessionCache(CacheKeys.SAML_SESSION), [CacheKeys.ROLES]: standardCache(CacheKeys.ROLES), + [CacheKeys.APP_CONFIG]: standardCache(CacheKeys.APP_CONFIG), [CacheKeys.CONFIG_STORE]: standardCache(CacheKeys.CONFIG_STORE), [CacheKeys.STATIC_CONFIG]: standardCache(CacheKeys.STATIC_CONFIG), [CacheKeys.PENDING_REQ]: standardCache(CacheKeys.PENDING_REQ), diff --git a/api/server/services/Config/app.js b/api/server/services/Config/app.js index e357b55d9f..a5e771eff7 100644 --- a/api/server/services/Config/app.js +++ b/api/server/services/Config/app.js @@ -4,6 +4,8 @@ const AppService = require('~/server/services/AppService'); const { setCachedTools } = require('./getCachedTools'); const getLogStores = require('~/cache/getLogStores'); +const BASE_CONFIG_KEY = '_BASE_'; + /** * Get the app configuration based on user context * @param {Object} [options] @@ -14,8 +16,8 @@ const getLogStores = require('~/cache/getLogStores'); async function getAppConfig(options = {}) { const { role, refresh } = options; - const cache = getLogStores(CacheKeys.CONFIG_STORE); - const cacheKey = role ? `${CacheKeys.APP_CONFIG}:${role}` : CacheKeys.APP_CONFIG; + const cache = getLogStores(CacheKeys.APP_CONFIG); + const cacheKey = role ? role : BASE_CONFIG_KEY; if (!refresh) { const cached = await cache.get(cacheKey); @@ -24,7 +26,7 @@ async function getAppConfig(options = {}) { } } - let baseConfig = await cache.get(CacheKeys.APP_CONFIG); + let baseConfig = await cache.get(BASE_CONFIG_KEY); if (!baseConfig) { logger.info('[getAppConfig] App configuration not initialized. Initializing AppService...'); baseConfig = await AppService(); @@ -37,7 +39,7 @@ async function getAppConfig(options = {}) { await setCachedTools(baseConfig.availableTools, { isGlobal: true }); } - await cache.set(CacheKeys.APP_CONFIG, baseConfig); + await cache.set(BASE_CONFIG_KEY, baseConfig); } // For now, return the base config