lru

package
v0.0.0-...-96bd095 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

type LRUCache struct {
	OnEvicted func(key string, value cache.Value) // (可选)移除缓存中某条记录时执行
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(maxBytes int64, onEvicted func(string, cache.Value)) *LRUCache

NewLRUCache 创建LRUCache

func (*LRUCache) Add

func (L *LRUCache) Add(key string, value cache.Value)

Add 添加一个值到缓存中

func (*LRUCache) Get

func (L *LRUCache) Get(key string) (value cache.Value, ok bool)

Get 查找键的值

func (*LRUCache) Len

func (L *LRUCache) Len() int

Len 缓存列表的条数

func (*LRUCache) RemoveOldest

func (L *LRUCache) RemoveOldest()

RemoveOldest 删除旧的记录

Jump to

Keyboard shortcuts

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