From c92d18611a2296540a9b3d5328e134e8878409b8 Mon Sep 17 00:00:00 2001 From: Claire Lin Date: Tue, 12 Mar 2024 11:41:55 -0700 Subject: [PATCH] add data version to key --- .../packages/ui-core/src/search/useGlobalSearch.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx b/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx index cd5ce497cc4cd..9f57a741fa9a9 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx @@ -259,6 +259,11 @@ type IndexBuffer = { cancel: () => void; }; +// This is the version of the secondary query, used as part of the cache key. +// When the data in the cache must be invalidated, this version should be bumped to prevent +// fetching stale data. +export const SEARCH_SECONDARY_DATA_VERSION = 'v1;'; + /** * Perform global search populated by two lazy queries, to be initialized upon some * interaction with the search input. Each query result list is packaged and sent to a worker @@ -292,7 +297,7 @@ export const useGlobalSearch = ({includeAssetFilters}: {includeAssetFilters: boo loading: secondaryDataLoading, } = useIndexedDBCachedQuery({ query: SEARCH_SECONDARY_QUERY, - key: 'SearchSecondary', + key: `SearchSecondary:${SEARCH_SECONDARY_DATA_VERSION}`, }); const consumeBufferEffect = useCallback(