easy_lru_cache

package module
v0.0.0-...-1249b32 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 5 Imported by: 0

README

2qc

Documentation

Index

Constants

View Source
const (
	// Default2QRecentRatio is the ratio of the 2Q cache dedicated
	// to recently added entries that have only been accessed once.
	Default2QRecentRatio = 0.20

	// Default2QGhostEntries is the default ratio of ghost
	// entries kept to track entries recently evicted
	Default2QGhostEntries = 0.80
)
View Source
const (
	ErrNotFoundInCache = "not found in cache"
)

Variables

This section is empty.

Functions

func NewLRU

func NewLRU(capacity int) (*lru, error)

NewLRU constructs an lru of the given size

func NewTwoQueue

func NewTwoQueue(size int, recentRation, ghostEntries float64) (*twoQueueCache, error)

NewTwoQueue creates a new twoQueueCache using the default values for the parameters.

func NewTwoQueueParams

func NewTwoQueueParams(size int, recentRatio, ghostRatio float64) (cache *twoQueueCache, err error)

NewTwoQueueParams creates a new twoQueueCache using the provided parameter values.

Types

type Key

type Key interface{}

Key is any value which is comparable. See http://golang.org/ref/spec#Comparison_operators for details.

type LRUCache

type LRUCache interface {
	Get(key interface{}) (value Value, err error)
	Put(key, value interface{}) (err error)
	Contains(key interface{}) (ok bool)
	Peek(key interface{}) (value interface{}, err error)
	Remove(key interface{}) (ok bool)
	Len() int
	RemoveOldest() (err error)
	Keys() []interface{}
	Purge()
}

type Value

type Value interface{}

Value is any value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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