UNPKG

transitory

Version:

In-memory cache with high hit rates via LFU eviction. Supports time-based expiration, automatic loading and metrics.

34 lines 960 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CacheNode = void 0; /** * Node in a double-linked list. */ var CacheNode = /** @class */ (function () { function CacheNode(key, value) { this.key = key; this.value = value; this.previous = this; this.next = this; } CacheNode.prototype.remove = function () { this.previous.next = this.next; this.next.previous = this.previous; this.next = this; this.previous = this; }; CacheNode.prototype.appendToTail = function (head) { var tail = head.previous; head.previous = this; tail.next = this; this.next = head; this.previous = tail; }; CacheNode.prototype.moveToTail = function (head) { this.remove(); this.appendToTail(head); }; return CacheNode; }()); exports.CacheNode = CacheNode; //# sourceMappingURL=CacheNode.js.map