Remote / foldkit-remote-server/fetch

checkCache

function · packages/remote-server/src/fetch.ts:584

function checkCache<P, R, Env, RP = never>(
  config: Omit<FetchConfig<P, R, Env, RP>, 'cache' | 'diagnostics'> & {
    readonly cache: {
      readonly visitor: P
    }
  },
  requests: ReadonlyArray<() => Request>,
  env: Env,
): Promise<void>

The cache's checker, for a test: serves each request twice through serveFetch with cache.check and a store in memory, so every public read is answered both as the visitor (kept, then from the store) and as whoever the request resolves to. Rejects naming each read whose answers differ, and when no read was public, which would check nothing. Give requests from at least two principals, a visitor's and someone's; each is a function, since a body is read once.