Skip to main content

invalidateTenantCache

@abimongo/core v1.1.4


@abimongo/core / invalidateTenantCache

Function: invalidateTenantCache()

invalidateTenantCache(tenantId, role): Promise<void>

Defined in: core/src/middleware/rbac/rbacMiddleware.ts:174

Invalidate the cache for a specific tenant and role

Parameters

tenantId

string

The ID of the tenant

role

string

The role to invalidate cache for

Returns

Promise<void>

This function removes the cached permissions for the specified tenant and role. It is useful when permissions change and you want to ensure the cache reflects the latest state. It logs the invalidation action and deletes the cache entry from Redis. This is particularly important in multi-tenant applications where each tenant may have different permissions.

Throws

If there is an issue with the Redis operation

Example

// Invalidate cache for tenant 'tenant123' with role 'admin'
await invalidateTenantCache('tenant123', 'admin');