MCPcopy Create free account
hub / github.com/cloudflare/computer / lookupResolveCache

Function lookupResolveCache

packages/dofs/src/fs/resolveCache.ts:59–72  ·  view source on GitHub ↗
(
  db: Database,
  canonicalPath: string,
)

Source from the content-addressed store, hash-verified

57// Look up a canonical path. Returns undefined on a miss, a positive
58// inode hit, or a negative (known-absent) hit. Bumps LRU recency.
59export function lookupResolveCache(
60 db: Database,
61 canonicalPath: string,
62): ResolveCacheHit | undefined {
63 const cache = cacheFor(db);
64 const value = cache.get(canonicalPath);
65 if (value === undefined) {
66 return undefined;
67 }
68 // Move to most-recent position for LRU eviction.
69 cache.delete(canonicalPath);
70 cache.set(canonicalPath, value);
71 return value === NEGATIVE ? { kind: "negative" } : { kind: "inode", inode: value };
72}
73
74// Cache a resolution. `inode === null` records a negative entry. No-op
75// while a transaction is active so the cache never reflects

Callers 1

resolveInodeFunction · 0.85

Calls 4

cacheForFunction · 0.70
getMethod · 0.65
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected