policy

package
v0.0.0-...-b521294 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ARC

type ARC[T comparable] struct {
	// contains filtered or unexported fields
}

func NewARC

func NewARC[T comparable]() *ARC[T]

func (*ARC[T]) Add

func (c *ARC[T]) Add(key T) (ok bool)

func (*ARC[T]) Clear

func (c *ARC[T]) Clear()

func (*ARC[T]) Evict

func (c *ARC[T]) Evict() (evicted T, ok bool)

func (*ARC[T]) EvictSkip

func (c *ARC[T]) EvictSkip(skip func(T) bool) (evicted T, ok bool)

func (*ARC[T]) Promote

func (c *ARC[T]) Promote(key T) bool

func (*ARC[T]) Values

func (c *ARC[T]) Values() iter.Seq[T]

type Policy

type Policy[T any] interface {
	Clear()
	Promote(T) (exists bool)
	Evict() (_ T, ok bool)
	EvictSkip(skip func(T) bool) (_ T, ok bool)

	// !ok if already exists.
	Add(T) (ok bool)

	// Hottest to coldest.
	// Safe for RLock.
	Values() iter.Seq[T]
}

Not concurrent safe.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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