MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / parseCache

Function parseCache

packages/redis/cachable.ts:141–153  ·  view source on GitHub ↗
(cached: string)

Source from the content-addressed store, hash-verified

139
140const DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*Z$/;
141const parseCache = (cached: string) => {
142 try {
143 return JSON.parse(cached, (_, value) => {
144 if (typeof value === 'string' && DATE_REGEX.test(value)) {
145 return new Date(value);
146 }
147 return value;
148 });
149 } catch (error) {
150 console.error('Failed to parse cache', error);
151 return null;
152 }
153};
154
155// L1 cache: short TTL to offload Redis; clear() invalidates Redis, other nodes may serve stale from LRU for up to this long
156const CACHEABLE_LRU_TTL_MS = 60 * 1000; // 60 seconds

Callers 2

getCacheFunction · 0.85
cachedFnFunction · 0.85

Calls 2

parseMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected