MCPcopy Create free account
hub / github.com/activejs/activejs / updateCache

Function updateCache

packages/core/src/lib/abstract-unit-base.ts:854–873  ·  view source on GitHub ↗

* @internal please do not use.

(value: T, cacheReplace?: boolean)

Source from the content-addressed store, hash-verified

852 * @internal please do not use.
853 */
854 private updateCache(value: T, cacheReplace?: boolean): void {
855 if (cacheReplace === true) {
856 this._cachedValues[this.cacheIndex] = value;
857 } else {
858 if (this.cachedValuesCount === 0 || this.cacheIndex === this.cachedValuesCount - 1) {
859 this._cachedValues.push(value);
860 if (this.cachedValuesCount > this.cacheSize) {
861 this._cachedValues.shift();
862 }
863 this._cacheIndex = this.cachedValuesCount - 1;
864 } else {
865 this._cachedValues.splice(
866 this.cacheIndex + 1,
867 this.cachedValuesCount - 1 - this.cacheIndex,
868 value
869 );
870 ++this._cacheIndex;
871 }
872 }
873 }
874
875 /**
876 * @internal please do not use.

Callers

nothing calls this directly

Calls 3

pushMethod · 0.80
shiftMethod · 0.80
spliceMethod · 0.80

Tested by

no test coverage detected