(namespace: string | undefined, fn: () => Promise<T>)
| 247 | * ``` |
| 248 | */ |
| 249 | export 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 | |
| 263 | export function withCacheEnabled<T>(enabledOverride: boolean | undefined, fn: () => Promise<T>) { |
| 264 | if (enabledOverride === undefined) { |
no test coverage detected
searching dependent graphs…