Add in-memory caching for online count, enable compression, and add staleTimes for router cache

This commit is contained in:
openhands committed 2026-07-09 18:24:58 +02:00
1 parent b058a3827b
commit deac10e00a
5 files changed
+51 -10

No files matched your search

+4 -1
View File
@@ -1,6 +1,7 @@
import { getTranslations } from "next-intl/server";
import Link from "next/link";
import { auth } from "@/lib/auth";
import { cached } from "@/lib/cache";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
@@ -15,7 +16,9 @@ export async function SiteHeader() {
let online = 0;
try {
online = await prisma.user.count({ where: { online: "1" } });
online = await cached("online_count", 10_000, () =>
prisma.user.count({ where: { online: "1" } }),
);
} catch {
online = 0;
}