MCPcopy
hub / github.com/vercel/next.js / addToHead

Method addToHead

packages/next/src/server/lib/lru-cache.ts:77–83  ·  view source on GitHub ↗

* Adds a node immediately after the head (marks as most recently used). * Used when inserting new items or when an item is accessed. * PRECONDITION: node must be disconnected (prev/next should be null)

(node: LRUNode<T>)

Source from the content-addressed store, hash-verified

75 * PRECONDITION: node must be disconnected (prev/next should be null)
76 */
77 private addToHead(node: LRUNode<T>): void {
78 node.prev = this.head
79 node.next = this.head.next
80 // head.next is always non-null (points to tail or another node)
81 this.head.next!.prev = node
82 this.head.next = node
83 }
84
85 /**
86 * Removes a node from its current position in the doubly-linked list.

Callers 2

moveToHeadMethod · 0.95
setMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected