MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / getOptionsForFetchCacheKey

Function getOptionsForFetchCacheKey

src/cache.ts:485–513  ·  view source on GitHub ↗
(options: RequestInit, bodyIdentity: unknown)

Source from the content-addressed store, hash-verified

483}
484
485function getOptionsForFetchCacheKey(options: RequestInit, bodyIdentity: unknown) {
486 const identity: Record<string, unknown> = {};
487
488 for (const [key, value] of Object.entries(options).sort(([keyA], [keyB]) =>
489 keyA.localeCompare(keyB),
490 )) {
491 if (key === 'headers' || IGNORED_FETCH_CACHE_OPTION_KEYS.has(key)) {
492 continue;
493 }
494
495 if (key === 'body') {
496 identity.body = bodyIdentity;
497 continue;
498 }
499
500 if (value == null || ['boolean', 'number', 'string'].includes(typeof value)) {
501 identity[key] = value;
502 continue;
503 }
504
505 return { cacheable: false, identity: undefined };
506 }
507
508 if (!Object.prototype.hasOwnProperty.call(options, 'body') && bodyIdentity !== undefined) {
509 identity.body = bodyIdentity;
510 }
511
512 return { cacheable: true, identity };
513}
514
515function getFetchCacheKey(
516 url: RequestInfo,

Callers 1

getFetchCacheKeyFunction · 0.85

Calls 2

callMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…