cache

package
v0.0.0-...-ec0d933 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expiration

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

func NewExpiration

func NewExpiration[K comparable, V any](capacity int, timeout time.Duration, interval time.Duration, onEvict func(key K, value V)) *Expiration[K, V]

func (*Expiration[K, V]) Delete

func (c *Expiration[K, V]) Delete(key K)

func (*Expiration[K, V]) Dispose

func (c *Expiration[K, V]) Dispose()

func (*Expiration[K, V]) Extend

func (c *Expiration[K, V]) Extend(key K)

func (*Expiration[K, V]) Get

func (c *Expiration[K, V]) Get(key K, callback func() (V, error)) (V, error)

func (*Expiration[K, V]) GetIfPresent

func (c *Expiration[K, V]) GetIfPresent(key K) (V, bool)

func (*Expiration[K, V]) Put

func (c *Expiration[K, V]) Put(key K, value V)

type LRU

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

LRU represents a Least Recently Used cache

Head -> Node -> <-prev- Node(value) -next-> <- Node <-Tail

func NewLRU

func NewLRU[K comparable, V any](capacity int, onEvict func(key K, value V)) *LRU[K, V]

func (*LRU[K, V]) Clear

func (l *LRU[K, V]) Clear()

func (*LRU[K, V]) Delete

func (l *LRU[K, V]) Delete(key K)

func (*LRU[K, V]) Get

func (l *LRU[K, V]) Get(key K) (V, bool)

func (*LRU[K, V]) Iterator

func (l *LRU[K, V]) Iterator() iter.Seq2[K, V]

func (*LRU[K, V]) Put

func (l *LRU[K, V]) Put(key K, value V)

func (*LRU[K, V]) ReverseIterator

func (l *LRU[K, V]) ReverseIterator() iter.Seq2[K, V]

func (*LRU[K, V]) Size

func (l *LRU[K, V]) Size() int

type NodeKV

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

NodeKV represents a node in the doubly linked list

Jump to

Keyboard shortcuts

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