perf : cache
CI / Verify (push) Successful in 1m56s
CI / Build immutable images and deploy (push) Successful in 3m12s

This commit is contained in:
2026-10-08 23:21:34 +07:00 Unverified
parent 36063fc214
commit 9580407a90
58 changed files with 5797 additions and 5336 deletions
+13 -1
View File
@@ -3,7 +3,7 @@ import { randomUUID } from "node:crypto";
import Redis from "ioredis";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { pageCacheTag } from "@/lib/cache/tags";
import { CATALOG_CACHE_TAG, GLOSSARY_CACHE_TAG, pageCacheTag } from "@/lib/cache/tags";
import { parseInvalidationEvent } from "@/lib/events/invalidation";
import {
createRedisOutboxTransport,
@@ -80,6 +80,18 @@ describeWithRedis("cross-replica Redis invalidation delivery", () => {
else process.env.REDIS_EVENT_PREFIX = originalEventPrefix;
});
it.each([
["catalog.updated", CATALOG_CACHE_TAG],
["glossary.updated", GLOSSARY_CACHE_TAG],
])("expires %s data across replicas", async (eventType, tag) => {
await processOutboxEvent({
topic: "admin", aggregateId: pageId, eventType,
payload: { id: pageId, version: 43 },
}, createRedisOutboxTransport(replicaA), invalidatedAt);
expect(JSON.parse((await replicaBCache.hget(redisCacheTagStateKey(), tag))!))
.toEqual({ expired: invalidatedAt });
});
it("shares tag state and publishes only the typed event envelope", async () => {
const channel = redisEventChannel(topic);
await replicaBEvents.subscribe(channel);