lru

package
v0.15.29 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2025 License: GPL-3.0, LGPL-3.0 Imports: 1 Imported by: 5

Documentation

Overview

Package lru provides wrapper types for go-ethereum's lru implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicLRU

type BasicLRU[K comparable, V any] struct {
	// contains filtered or unexported fields
}

BasicLRU is a simple LRU cache

func NewBasicLRU

func NewBasicLRU[K comparable, V any](capacity int) *BasicLRU[K, V]

NewBasicLRU creates a new BasicLRU

func (*BasicLRU[K, V]) Add

func (c *BasicLRU[K, V]) Add(key K, value V)

Add adds a value to the cache

func (*BasicLRU[K, V]) Get

func (c *BasicLRU[K, V]) Get(key K) (V, bool)

Get retrieves a value from the cache

func (*BasicLRU[K, V]) Len

func (c *BasicLRU[K, V]) Len() int

Len returns the number of items in the cache

type Cache

type Cache[K comparable, V any] struct {
	*BasicLRU[K, V]
}

Cache is a thread-safe LRU cache

func NewCache

func NewCache[K comparable, V any](capacity int) *Cache[K, V]

NewCache creates a new cache

type SizeConstrainedCache

type SizeConstrainedCache[K comparable, V any] struct {
	*BasicLRU[K, V]
	// contains filtered or unexported fields
}

SizeConstrainedCache is a size-constrained cache

func NewSizeConstrainedCache

func NewSizeConstrainedCache[K comparable, V any](maxSize uint64) *SizeConstrainedCache[K, V]

NewSizeConstrainedCache creates a new size-constrained cache

Jump to

Keyboard shortcuts

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