Session cache update on demand
I am using session cache in better-auth config to avoid hitting db each time i need session.
But in a scenario where I need to update the session for ex update the active Organization, the fresh session is not available to the better auth api calls.
And it still fetches from the cache. How do I update the cache as well when I do any update on the session.
Solution:Jump to solution
by default if you update use the builtin api to update active session, it'll update the cache. But if you need to manually invalidate, you can use
disableCookieCache
as a query param on auth.api.getSession
or authClient.getSession
2 Replies
Solution
by default if you update use the builtin api to update active session, it'll update the cache. But if you need to manually invalidate, you can use
disableCookieCache
as a query param on auth.api.getSession
or authClient.getSession
I have the same question, but the answer doesn't work for me. I want to update the session cache. If I add disableCookieCache to every
getSession
, I could disable the cache after all.