MCPcopy
hub / github.com/21st-dev/1code / getIfHashMatches

Method getIfHashMatches

src/main/lib/git/cache/git-cache.ts:51–68  ·  view source on GitHub ↗

* Get entry only if hash matches (for conditional updates).

(key: string, hash: string)

Source from the content-addressed store, hash-verified

49 * Get entry only if hash matches (for conditional updates).
50 */
51 getIfHashMatches(key: string, hash: string): T | null {
52 const entry = this.cache.get(key);
53 if (!entry) return null;
54
55 // Check TTL
56 if (Date.now() - entry.timestamp > this.config.maxAge) {
57 this.delete(key);
58 return null;
59 }
60
61 // Check hash
62 if (entry.hash !== hash) {
63 return null;
64 }
65
66 entry.accessCount++;
67 return entry.data;
68 }
69
70 /**
71 * Set an entry in the cache.

Callers 2

getParsedDiffMethod · 0.80

Calls 2

deleteMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected