lru

package
v0.0.0-...-dcebd05 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 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 Cache

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

Cache LRU缓存

func New

func New(maxBytes int, onEvicted func(key string, value 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)

Get 获取缓存的值

func (*Cache) Len

func (c *Cache) Len() int

Len 返回数据数量

func (*Cache) Remove

func (c *Cache) Remove(key string)

Remove 移除某个键

type Value

type Value interface {
	Len() int
	Expire() time.Time
}

Value 用于计算值占用了多少字节和过期时间

Jump to

Keyboard shortcuts

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