mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-27 21:58:08 -05:00
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial * CSS lint * Test CI * Add 1v1, 2v2, and 3v3 Tags (#1771) * Initial * CSS lint * Test CI * Rename step --------- Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
This commit is contained in:
@@ -2,25 +2,25 @@ import type { CacheEntry } from "@epic-web/cachified";
|
||||
import { LRUCache } from "lru-cache";
|
||||
|
||||
declare global {
|
||||
// This preserves the LRU cache during development
|
||||
// eslint-disable-next-line
|
||||
var __lruCache: LRUCache<string, CacheEntry<unknown>> | undefined;
|
||||
// This preserves the LRU cache during development
|
||||
var __lruCache: LRUCache<string, CacheEntry<unknown>> | undefined;
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noAssignInExpressions: trick to only create one
|
||||
export const cache = (global.__lruCache = global.__lruCache
|
||||
? global.__lruCache
|
||||
: new LRUCache<string, CacheEntry<unknown>>({ max: 5000 }));
|
||||
? global.__lruCache
|
||||
: new LRUCache<string, CacheEntry<unknown>>({ max: 5000 }));
|
||||
|
||||
export const ttl = (ms: number) =>
|
||||
process.env.NODE_ENV === "production" ? ms : 0;
|
||||
process.env.NODE_ENV === "production" ? ms : 0;
|
||||
|
||||
export function syncCached<T>(key: string, getFreshValue: () => T) {
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key) as T;
|
||||
}
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key) as T;
|
||||
}
|
||||
|
||||
const value = getFreshValue();
|
||||
cache.set(key, value as any);
|
||||
const value = getFreshValue();
|
||||
cache.set(key, value as any);
|
||||
|
||||
return value;
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user