MCPcopy Create free account
hub / github.com/idosal/git-mcp / getFromCache

Function getFromCache

src/api/utils/cache.ts:67–80  ·  view source on GitHub ↗

* Get a value from KV cache * @param key - The cache key * @param env - Environment with Cloudflare bindings * @returns The cached value or null if not found

(key: string, env: Env)

Source from the content-addressed store, hash-verified

65 * @returns The cached value or null if not found
66 */
67async function getFromCache(key: string, env: Env): Promise<any> {
68 // Check KV store for cached value
69 if (env?.CACHE_KV) {
70 try {
71 const result = await env.CACHE_KV.get(key, { type: "json" });
72 console.log(`Cache retrieval for key ${key}:`, result);
73 return result;
74 } catch (error) {
75 console.warn("Failed to retrieve from Cloudflare KV:", error);
76 }
77 }
78
79 return null;
80}
81
82/**
83 * Store a value in KV cache

Callers 4

getCachedFilePathFunction · 0.85
getCachedRobotsTxtFunction · 0.85
getIsIndexedFromCacheFunction · 0.85
getCachedFetchDocResultFunction · 0.85

Calls 3

logMethod · 0.80
warnMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected