MCPcopy Create free account
hub / github.com/KartikLabhshetwar/foliox / getCache

Function getCache

lib/utils/cache.ts:27–53  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

25}
26
27export async function getCache<T>(key: string): Promise<T | null> {
28 if (!Settings.CACHE_ENABLED) {
29 return null;
30 }
31
32 try {
33 const cacheEntry = await prisma.cache.findUnique({
34 where: { key },
35 });
36
37 if (!cacheEntry) {
38 return null;
39 }
40
41 if (cacheEntry.expiresAt < new Date()) {
42 await prisma.cache.delete({
43 where: { key },
44 });
45 return null;
46 }
47
48 return JSON.parse(cacheEntry.value) as T;
49 } catch (error) {
50 console.error(`Failed to get cache for key ${key}:`, error);
51 return null;
52 }
53}
54
55export async function setCache<T>(
56 key: string,

Callers 2

generatePortfolioProfileFunction · 0.90
getCachedPRsByOrgFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected