lru

package
v0.0.0-...-507ffb6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package lru implements a simple LRU cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle[K comparable] struct {
	// contains filtered or unexported fields
}

Handle is the actual LRU cache.

func New

func New[K comparable](capacity uint) *Handle[K]

New creates a new LRU cache.

func (*Handle[K]) Get

func (l *Handle[K]) Get(key K) (any, bool)

Get returns the value associated with the key and a boolean indicating if the key was found. If found the node is promoted to the front.

func (*Handle[K]) Len

func (l *Handle[K]) Len() uint

Len returns the number of elements in the cache.

func (*Handle[K]) Put

func (l *Handle[K]) Put(key K, value any)

Put puts the value associated with the key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL