From 4eae26879bb26cc1efd57c6241d70cdc24e536a0 Mon Sep 17 00:00:00 2001 From: Diljit Date: Mon, 5 May 2025 17:55:25 +0530 Subject: [PATCH] chore: add feature flag for app computation cache (#40543) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 8c69931e4d5fb6b319883e8d1ba33f553029f346 > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Fri, 02 May 2025 07:00:53 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Introduced a new feature flag to control the computation cache capability. - **Enhancements** - Added checks to ensure computation caching only occurs when the corresponding feature flag is enabled. --- app/client/src/ce/entities/FeatureFlag.ts | 2 ++ .../AppComputationCache/AppComputationCache.test.ts | 5 +++++ .../src/workers/common/AppComputationCache/index.ts | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) 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; }