Key Without A Tenant
Workspace settings are cached in front of a correctly tenant-scoped query. Workspace slugs are unique within a tenant, not across tenants.
const cacheKey = (slug: string) => `settings:${slug}`
export async function getSettings(slug: string, tenantId: string) {
const hit = await redis.get(cacheKey(slug))
if (hit) return JSON.parse(hit) as Settings
const row = await db.query.settings.findFirst({
where: and(eq(settings.slug, slug), eq(settings.tenantId, tenantId))
})
await redis.set(cacheKey(slug), JSON.stringify(row), { EX: 300 })
return row
}
Under what condition does one tenant read another tenant's settings?
Sign in to answer questions and track your progress
Sign In