perf : cache
This commit is contained in:
@@ -3,8 +3,12 @@ import { join } from "node:path";
|
||||
import { sql } from "drizzle-orm";
|
||||
import * as z from "zod";
|
||||
|
||||
import { CATALOG_CACHE_TAG, DIRECTORY_CACHE_TAG, STYGIAN_CACHE_TAG } from "@/lib/cache/tags";
|
||||
import { createRedisOutboxTransport } from "@/lib/outbox/processor";
|
||||
|
||||
import { getDb } from "@/db/client";
|
||||
import {
|
||||
outboxEvents,
|
||||
catalogArtifacts,
|
||||
catalogCharacters,
|
||||
catalogMaterials,
|
||||
@@ -644,7 +648,15 @@ async function syncCatalogVersion(version: string, control?: SyncControl): Promi
|
||||
imageKey: item.imageKey,
|
||||
})),
|
||||
);
|
||||
const eventId = crypto.randomUUID();
|
||||
await tx.insert(outboxEvents).values({
|
||||
topic: "admin", aggregateId: eventId, eventType: "catalog.updated",
|
||||
payload: { id: eventId, version: Date.now() },
|
||||
});
|
||||
});
|
||||
await createRedisOutboxTransport(await getRedisClient()).invalidate(
|
||||
[CATALOG_CACHE_TAG, DIRECTORY_CACHE_TAG, STYGIAN_CACHE_TAG], Date.now(),
|
||||
);
|
||||
await control?.report("database", 1, 1, "บันทึก Catalog แล้ว");
|
||||
await storage.write("catalog/current.json", JSON.stringify({
|
||||
version,
|
||||
|
||||
Reference in New Issue
Block a user