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

Function withCacheNamespace

src/cache.ts:249–261  ·  view source on GitHub ↗
(namespace: string | undefined, fn: () => Promise<T>)

Source from the content-addressed store, hash-verified

247 * ```
248 */
249export function withCacheNamespace<T>(namespace: string | undefined, fn: () => Promise<T>) {
250 if (!namespace) {
251 return fn();
252 }
253
254 const parentNamespace = getCurrentCacheNamespace();
255 if (parentNamespace === namespace) {
256 return fn();
257 }
258
259 const scopedNamespace = parentNamespace ? `${parentNamespace}:${namespace}` : namespace;
260 return cacheNamespaceStorage.run({ namespace: scopedNamespace }, fn);
261}
262
263export function withCacheEnabled<T>(enabledOverride: boolean | undefined, fn: () => Promise<T>) {
264 if (enabledOverride === undefined) {

Callers 5

cache.test.tsFile · 0.90
mistral.test.tsFile · 0.90
runEvalFunction · 0.90
processEvalStepMethod · 0.90

Calls 3

getCurrentCacheNamespaceFunction · 0.85
fnFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…