lru

package
v0.0.0-...-474052a Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 1 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 {
	OnEvicted func(string, Value) // 删除时的回调函数
	// contains filtered or unexported fields
}

func NewCache

func NewCache(maxBytes int64, onEvicted func(string, Value)) *Cache

func (*Cache) Add

func (c *Cache) Add(key string, value Value)

Add 已存在则更新,不存在则新增。依据内存限制,先删后加

func (*Cache) Get

func (c *Cache) Get(key string) (Value, bool)

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

type Value

type Value interface {
	Len() int
}

Jump to

Keyboard shortcuts

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