Refresh Suggest hotel label from live CMS setting.
Local Build and Deploy / deploy (push) Successful in 56s
Local Build and Deploy / deploy (push) Successful in 56s
Avoid stale SSR/Redis cache keeping Suggest IT after habbo_gamedata_hotel changes. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
785c1b6976
commit
a798999440
5 files changed
+49
-10
No files matched your search
@@ -7,9 +7,9 @@ vi.mock("@/lib/prisma", () => ({
|
||||
|
||||
import { siteSettings } from "./site-settings";
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
findMany.mockReset();
|
||||
siteSettings.reload();
|
||||
await siteSettings.reload();
|
||||
});
|
||||
|
||||
describe("siteSettings", () => {
|
||||
@@ -39,7 +39,7 @@ describe("siteSettings", () => {
|
||||
await siteSettings.get("hotel_name");
|
||||
await siteSettings.getBool("hotel_name");
|
||||
expect(findMany).toHaveBeenCalledTimes(1);
|
||||
siteSettings.reload();
|
||||
await siteSettings.reload();
|
||||
await siteSettings.get("hotel_name");
|
||||
expect(findMany).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
@@ -84,13 +84,17 @@ class SiteSettings {
|
||||
create: { key, value },
|
||||
update: { value },
|
||||
});
|
||||
this.reload();
|
||||
await this.reload();
|
||||
}
|
||||
|
||||
reload(): void {
|
||||
async reload(): Promise<void> {
|
||||
this.cache = null;
|
||||
if (redis) {
|
||||
redis.del(REDIS_CACHE_KEY).catch(() => {});
|
||||
try {
|
||||
await redis.del(REDIS_CACHE_KEY);
|
||||
} catch {
|
||||
// non-critical
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user