MCPcopy
hub / github.com/loopbackio/loopback-next / _cacheValue

Method _cacheValue

packages/context/src/binding.ts:422–432  ·  view source on GitHub ↗

* Cache the resolved value by the binding scope * @param resolutionCtx - The resolution context * @param result - The calculated value for the binding

(
    resolutionCtx: Context,
    result: ValueOrPromise<T>,
  )

Source from the content-addressed store, hash-verified

420 * @param result - The calculated value for the binding
421 */
422 private _cacheValue(
423 resolutionCtx: Context,
424 result: ValueOrPromise<T>,
425 ): ValueOrPromise<T> {
426 // Initialize the cache as a weakmap keyed by context
427 if (!this._cache) this._cache = new WeakMap<Context, ValueOrPromise<T>>();
428 if (this.scope !== BindingScope.TRANSIENT) {
429 this._cache.set(resolutionCtx!, result);
430 }
431 return result;
432 }
433
434 /**
435 * Clear the cache

Callers 1

getValueMethod · 0.95

Calls 1

setMethod · 0.65

Tested by

no test coverage detected