cache

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 6 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 struct {
	Policy Policy
	Items  map[Key]ItemMeta
	// contains filtered or unexported fields
}

func (*Cache) Candidate

func (me *Cache) Candidate() (Item, bool)

func (*Cache) Clear

func (me *Cache) Clear()

func (*Cache) Filled

func (me *Cache) Filled() int64

func (*Cache) NumItems

func (me *Cache) NumItems() int

func (*Cache) Remove

func (me *Cache) Remove(k Key)

func (*Cache) String

func (me *Cache) String() string

func (*Cache) Update

func (me *Cache) Update(i Item)

func (*Cache) Used

func (me *Cache) Used() int64

type Item

type Item struct {
	Key
	ItemMeta
}

type ItemMeta

type ItemMeta struct {
	Size     int64
	CanEvict bool
	Usage
}

type Key

type Key = string

type LruPolicy

type LruPolicy struct {
	// contains filtered or unexported fields
}

func (*LruPolicy) Candidate

func (me *LruPolicy) Candidate() (k Key, ok bool)

func (*LruPolicy) Forget

func (me *LruPolicy) Forget(k Key)

func (*LruPolicy) NumItems

func (me *LruPolicy) NumItems() int

func (*LruPolicy) Update

func (me *LruPolicy) Update(k Key, u Usage)

type Policy

type Policy interface {
	Candidate() (Key, bool)
	Update(Key, Usage)
	Forget(Key)
	NumItems() int
}

type Usage

type Usage interface {
	Less(Usage) bool
}

Jump to

Keyboard shortcuts

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