MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / NewLRU

Function NewLRU

cache/lru.go:30–37  ·  view source on GitHub ↗

NewLRU represent initiate lru cache with capacity

(capacity int)

Source from the content-addressed store, hash-verified

28
29// NewLRU represent initiate lru cache with capacity
30func NewLRU(capacity int) LRU {
31 return LRU{
32 dl: linkedlist.NewDoubly[any](),
33 storage: make(map[string]*linkedlist.Node[any], capacity),
34 size: 0,
35 capacity: capacity,
36 }
37}
38
39// Get value from lru
40// if not found, return nil

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected