diff --git a/app/client/src/ce/entities/FeatureFlag.ts b/app/client/src/ce/entities/FeatureFlag.ts index c9ed5ba670..b16c34ca15 100644 --- a/app/client/src/ce/entities/FeatureFlag.ts +++ b/app/client/src/ce/entities/FeatureFlag.ts @@ -58,6 +58,7 @@ export const FEATURE_FLAG = { release_git_package_enabled: "release_git_package_enabled", license_external_saas_plugins_enabled: "license_external_saas_plugins_enabled", + release_computation_cache_enabled: "release_computation_cache_enabled", } as const; export type FeatureFlag = keyof typeof FEATURE_FLAG; @@ -106,6 +107,7 @@ export const DEFAULT_FEATURE_FLAG_VALUE: FeatureFlags = { release_table_custom_sort_function_enabled: false, release_git_package_enabled: false, license_external_saas_plugins_enabled: false, + release_computation_cache_enabled: false, }; export const AB_TESTING_EVENT_KEYS = { diff --git a/app/client/src/workers/common/AppComputationCache/AppComputationCache.test.ts b/app/client/src/workers/common/AppComputationCache/AppComputationCache.test.ts index 223097799c..5f6369dc74 100644 --- a/app/client/src/workers/common/AppComputationCache/AppComputationCache.test.ts +++ b/app/client/src/workers/common/AppComputationCache/AppComputationCache.test.ts @@ -7,6 +7,8 @@ import { APP_MODE } from "entities/App"; import localforage from "localforage"; import loglevel from "loglevel"; import { AppComputationCache } from "./index"; +import { WorkerEnv } from "workers/Evaluation/handlers/workerEnv"; +import type { FeatureFlags } from "ee/entities/FeatureFlag"; jest.useFakeTimers(); @@ -68,6 +70,9 @@ describe("AppComputationCache", () => { beforeEach(() => { jest.clearAllMocks(); AppComputationCache.resetInstance(); + WorkerEnv.setFeatureFlags({ + release_computation_cache_enabled: true, + } as FeatureFlags); // Now instantiate the singleton after mocks are set up appComputationCache = AppComputationCache.getInstance(); diff --git a/app/client/src/workers/common/AppComputationCache/index.ts b/app/client/src/workers/common/AppComputationCache/index.ts index f872a6b6c8..7b1a2b926b 100644 --- a/app/client/src/workers/common/AppComputationCache/index.ts +++ b/app/client/src/workers/common/AppComputationCache/index.ts @@ -9,6 +9,7 @@ import { } from "./types"; import debounce from "lodash/debounce"; import { isFinite, isNumber, isString } from "lodash"; +import { WorkerEnv } from "workers/Evaluation/handlers/workerEnv"; interface ICachedData { value: T; @@ -82,6 +83,12 @@ export class AppComputationCache { 5000, ); + isComputationCacheFeatureEnabled() { + const featureFlags = WorkerEnv.getFeatureFlags(); + + return featureFlags["release_computation_cache_enabled"] || false; + } + /** * Check if the computation result should be cached based on the app mode configuration * @returns - A boolean indicating whether the cache should be enabled for the given app mode @@ -95,7 +102,8 @@ export class AppComputationCache { if ( !this.isAppModeValid(appMode) || !this.isTimestampValid(timestamp) || - !this.isDSLVersionValid(dslVersion) + !this.isDSLVersionValid(dslVersion) || + !this.isComputationCacheFeatureEnabled() ) { return false; }