lru

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Key interface{}
	Val interface{}
}

type ILru

type ILru interface {
	Get(interface{}, NewLruElement) *Element
	// contains filtered or unexported methods
}

func NewLru

func NewLru(lruMaxLength int, mThresholdFactor float32) ILru

type Lru

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

func (*Lru) Get

func (r *Lru) Get(i interface{}, fn NewLruElement) *Element

Get 获取一个元素, 如果没有的话就用 NewLruElement 新建一个 如果已经超容量了, 就会触发清理, 将最近最少使用的元素移除(链表尾节点前移)

type NewLruElement

type NewLruElement func(interface{}) *Element

Jump to

Keyboard shortcuts

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