cache

package
v0.0.0-...-c75119f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 9 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[V any] interface {
	Sizer
	// Get returns the value for the given id, and a boolean to indicate whether the key was found.
	// If the key is not present, the zero value is returned.
	Get(id pcommon.TraceID) (V, bool)
	// Put sets the value for a given id
	Put(id pcommon.TraceID, v V)
	// Delete deletes the value for the given id
	Delete(id pcommon.TraceID)
	// Values returns a slice of all values in the cache.
	// The slice must be safe to modify by the caller.
	Values() []V
	// Keys returns a slice of all trace IDs in the cache
	Keys() []pcommon.TraceID
	// Clear removes all entry from the cache
	Clear()
}

Cache is a cache using a pcommon.TraceID as the key and any generic type as the value.

func NewLRUCache

func NewLRUCache[V any](size int, onEvicted func(pcommon.TraceID, V), telemetry *metadata.TelemetryBuilder) (Cache[V], error)

NewLRUCache returns a new lruCache. The size parameter indicates the amount of keys the cache will hold before it starts evicting the least recently used key.

func NewNopDecisionCache

func NewNopDecisionCache[V any]() Cache[V]

func NewTieredCache

func NewTieredCache[V priority.Getter](primary Cache[V], secondary Cache[V]) (Cache[V], error)

type Sizer

type Sizer interface {
	// Size returns the number of entries in the cache
	Size() int
	// Resize sets a new size for the cache.
	Resize(size int)
}

Jump to

Keyboard shortcuts

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