perf(access): TTL-кэш getAccessibleTaskIds с точечной инвалидацией
Шаг 0.12 плана production-готовности: - accessibleTasksCache (45с) per userId:orgId внутри storage-метода - инвалидация в storage-слое: роли, делегирования, form access, assignees, createTask/updateTask, appRole пользователя - 9 новых юнит-тестов (65/65 зелёные)
This commit is contained in:
@@ -3,6 +3,7 @@ import { db } from "../db";
|
||||
import { eq, and, desc, exists, sql } from "drizzle-orm";
|
||||
import crypto from "crypto";
|
||||
import { UserProfileStorage } from "./user-profile.storage";
|
||||
import { invalidateAccessibleTasksForOrg } from "../utils/cache";
|
||||
export class FormsStorage extends UserProfileStorage {
|
||||
// Forms
|
||||
async getForm(id: number, organizationId: number): Promise<Form | undefined> {
|
||||
@@ -35,6 +36,10 @@ export class FormsStorage extends UserProfileStorage {
|
||||
.set({ ...updates, updatedAt: new Date() })
|
||||
.where(and(eq(forms.id, id), eq(forms.organizationId, organizationId)))
|
||||
.returning();
|
||||
// visibility/createdBy меняют доступ к задачам формы — сброс кэша по организации
|
||||
if ('visibility' in updates || 'createdBy' in updates) {
|
||||
invalidateAccessibleTasksForOrg(organizationId);
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user