Can you please explain this better to me? Is gcTime
a way to avoid the getItem
call?
#6214
-
I'm using the latest v5 version (which is AMAZING, thanks!) and the In the docs there is this statement:
I have a (big) doubt: if I'm still in Is this the logic, right? import {
experimental_createPersister,
type AsyncStorage,
} from "@tanstack/query-persist-client-core";
import { get, set, del, createStore, type UseStore } from "idb-keyval";
function newIdbStorage(idbStore: UseStore): AsyncStorage {
return {
getItem: async (key) => await get(key, idbStore),
setItem: async (key, value) => await set(key, value, idbStore),
removeItem: async (key) => await del(key, idbStore),
};
}
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
gcTime: 1000 * 30, // 30 seconds
persister: !browser
? undefined
: experimental_createPersister({
storage: newIdbStorage(createStore("db_name", "store_name")),
maxAge: 1000 * 60 * 60 * 12, // 12 hours
}),
},
},
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This setup will work as follows:
This way you can keep your memory usage lower, since unused queries can be garbage collected, while still being stored in idb for example. |
Beta Was this translation helpful? Give feedback.
This setup will work as follows:
This way you can keep your memory usage lower, since unused queries can be garbage collected, while still bein…