lru

package
v3.8.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 4 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvictCallback

type EvictCallback[K comparable, V any] simplelru.EvictCallback[K, V]

type ExpirationLRU

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

func (*ExpirationLRU[K, V]) Del

func (x *ExpirationLRU[K, V]) Del(key K) bool

func (*ExpirationLRU[K, V]) Get

func (x *ExpirationLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error)

func (*ExpirationLRU[K, V]) GetBatch added in v3.8.1

func (x *ExpirationLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error)

func (*ExpirationLRU[K, V]) Set added in v3.8.1

func (x *ExpirationLRU[K, V]) Set(key K, value V)

func (*ExpirationLRU[K, V]) SetHas added in v3.8.0

func (x *ExpirationLRU[K, V]) SetHas(key K, value V) bool

func (*ExpirationLRU[K, V]) Stop

func (x *ExpirationLRU[K, V]) Stop()

type LRU

type LRU[K comparable, V any] interface {
	Get(key K, fetch func() (V, error)) (V, error)
	Set(key K, value V)
	SetHas(key K, value V) bool
	GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error)
	Del(key K) bool
	Stop()
}

func NewExpirationLRU

func NewExpirationLRU[K comparable, V any](size int, successTTL, failedTTL time.Duration, target Target, onEvict EvictCallback[K, V]) LRU[K, V]

func NewSlotLRU

func NewSlotLRU[K comparable, V any](slotNum int, hash func(K) uint64, create func() LRU[K, V]) LRU[K, V]

type LayLRU

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

func NewLayLRU

func NewLayLRU[K comparable, V any](size int, successTTL, failedTTL time.Duration, target Target, onEvict EvictCallback[K, V]) *LayLRU[K, V]

func (*LayLRU[K, V]) Del

func (x *LayLRU[K, V]) Del(key K) bool

func (*LayLRU[K, V]) Get

func (x *LayLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error)

func (*LayLRU[K, V]) GetBatch added in v3.8.1

func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error)

func (*LayLRU[K, V]) Set added in v3.8.1

func (x *LayLRU[K, V]) Set(key K, value V)

func (*LayLRU[K, V]) SetHas added in v3.8.0

func (x *LayLRU[K, V]) SetHas(key K, value V) bool

func (*LayLRU[K, V]) Stop

func (x *LayLRU[K, V]) Stop()

type Target

type Target interface {
	IncrGetHit()
	IncrGetSuccess()
	IncrGetFailed()

	IncrDelHit()
	IncrDelNotFound()
}

Jump to

Keyboard shortcuts

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