package internal
import "github.com/hashicorp/golang-lru/v2/internal"
Index ¶
- type Entry
- type LruList
- func NewList[K comparable, V any]() *LruList[K, V]
- func (l *LruList[K, V]) Back() *Entry[K, V]
- func (l *LruList[K, V]) Init() *LruList[K, V]
- func (l *LruList[K, V]) Length() int
- func (l *LruList[K, V]) MoveToFront(e *Entry[K, V])
- func (l *LruList[K, V]) PushFront(k K, v V) *Entry[K, V]
- func (l *LruList[K, V]) PushFrontExpirable(k K, v V, expiresAt time.Time) *Entry[K, V]
- func (l *LruList[K, V]) Remove(e *Entry[K, V]) V
Types ¶
type Entry ¶
type Entry[K comparable, V any] struct { // The LRU Key of this element. Key K // The Value stored with this element. Value V // The time this element would be cleaned up, optional ExpiresAt time.Time // The expiry bucket item was put in, optional ExpireBucket uint8 // contains filtered or unexported fields }
Entry is an LRU Entry
func (*Entry[K, V]) PrevEntry ¶
PrevEntry returns the previous list element or nil.
type LruList ¶
type LruList[K comparable, V any] struct { // contains filtered or unexported fields }
LruList represents a doubly linked list. The zero Value for LruList is an empty list ready to use.
func NewList ¶
func NewList[K comparable, V any]() *LruList[K, V]
NewList returns an initialized list.
func (*LruList[K, V]) Back ¶
Back returns the last element of list l or nil if the list is empty.
func (*LruList[K, V]) Init ¶
Init initializes or clears list l.
func (*LruList[K, V]) Length ¶
Length returns the number of elements of list l. The complexity is O(1).
func (*LruList[K, V]) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*LruList[K, V]) PushFront ¶
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*LruList[K, V]) PushFrontExpirable ¶
PushFrontExpirable inserts a new expirable element e with Value v at the front of list l and returns e.
func (*LruList[K, V]) Remove ¶
Remove removes e from its list, decrements l.len
Source Files ¶
- Version
- v2.0.7 (latest)
- Published
- Sep 21, 2023
- Platform
- windows/amd64
- Imports
- 1 packages
- Last checked
- 1 week ago –
Tools for package owners.