perf : cache
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user