eviction

package
v0.0.0-...-a9d0937 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T any] interface {
	// Insert a value into the set. The value may not already be
	// present within the set.
	Insert(value T)

	// Touch the element stored in the set corresponding with the
	// provided value. Touching is used to indicate that the object
	// corresponding with the value was recently used.
	//
	// For cache replacement policies such as Least Recently Used
	// (LRU), this function causes the element in the set to be
	// moved to the back of a queue. For cache replacement policies
	// such as Random Replacement (RR), this function has no effect.
	//
	// The value must already be present within the set.
	Touch(value T)

	// Peek at the element that needs to be removed from cache
	// first. This function may not be called on empty sets.
	Peek() T

	// Remove the element from the set that was last returned by
	// Peek().
	Remove()
}

Set of values that need to be retained according to a cache replacement policy. This set does not permit concurrent access.

func NewFIFOSet

func NewFIFOSet[T any]() Set[T]

NewFIFOSet creates a new cache replacement set that implements the First In First Out (FIFO) policy.

https://en.wikipedia.org/wiki/Cache_replacement_policies#First_in_first_out_(FIFO)

func NewLRUSet

func NewLRUSet[T comparable]() Set[T]

NewLRUSet creates a new cache replacement set that implements the Least Recently Used (LRU) policy.

https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)

func NewMetricsSet

func NewMetricsSet[T any](base Set[T], name string) Set[T]

NewMetricsSet is a decorator for Set that exposes the total number of operations performed against the underlying Set through Prometheus.

func NewRRSet

func NewRRSet[T any]() Set[T]

NewRRSet creates a new cache replacement set that implements the Random Replacement (RR) policy.

https://en.wikipedia.org/wiki/Cache_replacement_policies#Random_replacement_(RR)

func NewSetFromConfiguration

func NewSetFromConfiguration[T comparable](cacheReplacementPolicy pb.CacheReplacementPolicy) (Set[T], error)

NewSetFromConfiguration creates a new cache replacement set using an algorithm specified in a Protobuf enumeration value.

Jump to

Keyboard shortcuts

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