UNPKG

transitory

Version:

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

29 lines 674 B
/** * Node in a double-linked list. */ export class CacheNode { constructor(key, value) { this.key = key; this.value = value; this.previous = this; this.next = this; } remove() { this.previous.next = this.next; this.next.previous = this.previous; this.next = this; this.previous = this; } appendToTail(head) { const tail = head.previous; head.previous = this; tail.next = this; this.next = head; this.previous = tail; } moveToTail(head) { this.remove(); this.appendToTail(head); } } //# sourceMappingURL=CacheNode.js.map