lru

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 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 {
	OnEvicted func(key string, value cache.Valuer) // (可选)移除缓存中某条记录时执行
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(maxBytes int64, onEvicted func(string, cache.Valuer)) *Cache

NewLRUCache 创建LRUCache

func (*Cache) Add

func (c *Cache) Add(key string, value cache.Valuer)

Add 添加一个值到缓存中

func (*Cache) Clear

func (c *Cache) Clear()

Clear 清空全部数据

func (*Cache) Get

func (c *Cache) Get(key string) (value cache.Valuer, ok bool)

Get 查找键的值

func (*Cache) Len

func (c *Cache) Len() int

Len 缓存列表的条数

func (*Cache) Remove

func (c *Cache) Remove(key string)

Remove 移除指定key的数据

type Value

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

func NewValue

func NewValue(data []byte, expire int64, groupName string) *Value

func (*Value) Bytes

func (v *Value) Bytes() []byte

func (*Value) Expire

func (v *Value) Expire() int64

func (*Value) GroupName

func (v *Value) GroupName() string

func (*Value) Len

func (v *Value) Len() int

func (*Value) SetExpire

func (v *Value) SetExpire(timestamp int64)

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

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