parent
77a7cc86a5
commit
2f4521dd74
@ -0,0 +1,23 @@
|
||||
import { CACHE_SCOPE_PUBLIC } from '$libs/cach';
|
||||
import type { AuthClientCachPort } from '$libs/auth/contracts';
|
||||
import type { ActiveCache } from '$cach';
|
||||
import type { ActivePermissions } from '$perm';
|
||||
|
||||
export function createAuthCacheInvalidator(input: {
|
||||
readonly cache: ActiveCache;
|
||||
readonly permissions: () => ActivePermissions | undefined;
|
||||
}): AuthClientCachPort {
|
||||
return {
|
||||
async invalidate(event) {
|
||||
input.permissions()?.invalidate();
|
||||
await Promise.all(
|
||||
event.tags.map((tag) =>
|
||||
input.cache.invalidate({
|
||||
tag,
|
||||
scope: CACHE_SCOPE_PUBLIC
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Reference in new issue