RBAC Improvements
Caching improvements Maker-Checker Implementation
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
import { QueryClient, QueryKey, InvalidateQueryFilters } from '@tanstack/react-query';
|
||||
import { bumpMutationEpoch } from '../services/httpClient';
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 1000 * 60 * 3, // 3 minutes default cache
|
||||
staleTime: 1000 * 60 * 2, // 2 minutes fresh in memory
|
||||
gcTime: 1000 * 60 * 10, // 10 minutes cache retention
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: true,
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Invalidates queries while simultaneously bumping the mutation epoch.
|
||||
* This guarantees that the background refetch generates a fresh query parameter (_v)
|
||||
* that bypasses backend ASP.NET Core OutputCaching.
|
||||
*/
|
||||
export async function invalidateAndBustCache(
|
||||
client: QueryClient,
|
||||
filters?: InvalidateQueryFilters
|
||||
): Promise<void> {
|
||||
bumpMutationEpoch();
|
||||
await client.invalidateQueries(filters);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user