lru

package
v3.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[T CacheIdentifier] struct {
	// contains filtered or unexported fields
}

Cache is a thread-safe cache of generic entries.

func NewCache

func NewCache[T CacheIdentifier](capacity int) *Cache[T]

func (*Cache[T]) Add

func (sl *Cache[T]) Add(entry T) error

func (*Cache[T]) CreateAndAdd

func (sl *Cache[T]) CreateAndAdd(generate func() (T, error)) (T, error)

func (*Cache[T]) Delete

func (sl *Cache[T]) Delete(entry T) (present bool)

func (*Cache[T]) DeleteByID

func (sl *Cache[T]) DeleteByID(id string) (present bool)

func (*Cache[T]) Get

func (sl *Cache[T]) Get(entry T) (T, bool)

func (*Cache[T]) GetByID

func (sl *Cache[T]) GetByID(id string) (T, bool)

func (*Cache[T]) List

func (sl *Cache[T]) List() []T

func (*Cache[T]) MostRecentOrCreate

func (sl *Cache[T]) MostRecentOrCreate(generate func() (T, error)) (T, error)

func (*Cache[T]) Newest

func (sl *Cache[T]) Newest() (T, bool)

func (*Cache[T]) Size

func (sl *Cache[T]) Size() int

type CacheIdentifier

type CacheIdentifier interface {
	Identifier() string
}

Jump to

Keyboard shortcuts

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