feat : add stygian guide
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import "server-only";
|
||||
|
||||
import { cacheLife, cacheTag } from "next/cache";
|
||||
|
||||
import { getActiveStygianSchedule } from "@/lib/stygian/repository";
|
||||
import { STYGIAN_CACHE_TAG } from "@/lib/cache/tags";
|
||||
|
||||
export { STYGIAN_CACHE_TAG };
|
||||
|
||||
export async function getCachedActiveStygianSchedule() {
|
||||
"use cache: remote";
|
||||
cacheLife({ stale: 30, revalidate: 60, expire: 60 * 60 });
|
||||
cacheTag(STYGIAN_CACHE_TAG);
|
||||
return getActiveStygianSchedule();
|
||||
}
|
||||
Vendored
+2
@@ -3,12 +3,14 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
cacheTagsForOutboxEvent,
|
||||
DIRECTORY_CACHE_TAG,
|
||||
STYGIAN_CACHE_TAG,
|
||||
} from "./tags";
|
||||
|
||||
describe("public cache tags", () => {
|
||||
it("maps outbox events to dependency-aware tags", () => {
|
||||
expect(cacheTagsForOutboxEvent({ eventType: "directory.updated", aggregateId: "id" })).toEqual([DIRECTORY_CACHE_TAG]);
|
||||
expect(cacheTagsForOutboxEvent({ eventType: "page.updated", aggregateId: "page" })).toEqual(["buzz:page:page"]);
|
||||
expect(cacheTagsForOutboxEvent({ eventType: "stygian.updated", aggregateId: "5269001" })).toEqual([STYGIAN_CACHE_TAG]);
|
||||
expect(cacheTagsForOutboxEvent({ eventType: "admin.updated", aggregateId: "id" })).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+2
@@ -1,5 +1,6 @@
|
||||
export const DIRECTORY_CACHE_TAG = "buzz:directory";
|
||||
export const GLOSSARY_CACHE_TAG = "buzz:glossary";
|
||||
export const STYGIAN_CACHE_TAG = "buzz:stygian";
|
||||
|
||||
export function pageCacheTag(pageId: string): string {
|
||||
return `buzz:page:${pageId}`;
|
||||
@@ -13,5 +14,6 @@ export type OutboxCacheEvent = {
|
||||
export function cacheTagsForOutboxEvent(event: OutboxCacheEvent): string[] {
|
||||
if (event.eventType === "directory.updated") return [DIRECTORY_CACHE_TAG];
|
||||
if (event.eventType === "page.updated") return [pageCacheTag(event.aggregateId)];
|
||||
if (event.eventType === "stygian.updated") return [STYGIAN_CACHE_TAG];
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user