xsync

package
v0.0.0-...-29d029c Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: BSD-3-Clause Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUMap

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

LRUMap 只持有最近使用元素的map。并发安全。 按批次(区块)清理长期不用的元素。 总是提升Store/Load的元素到最新区块。空间不足时,清理最后一个区块和区块内的元素。

func NewLRUMap

func NewLRUMap(chunkCapacity int, chunkNum int) *LRUMap

NewLRUMap 创建LRUMap。 总容量为chunkCapacity*chunkNum。

func (*LRUMap) Load

func (m *LRUMap) Load(key interface{}) (value interface{}, ok bool)

Load 查找元素。如果找到,记录元素到最新区块。

func (*LRUMap) SilentLoad

func (m *LRUMap) SilentLoad(key interface{}) (value interface{}, upgrade func(), ok bool)

SilentLoad 查找元素。如果找到,返回一个记录元素到最新区块的函数。

func (*LRUMap) Store

func (m *LRUMap) Store(key interface{}, value interface{})

Store 存储数据。记录元素到最新区块。 被覆盖的value会跟随最近不用的value,等待被清理。

Directories

Path Synopsis
internal
golang-lru/simplelru
Package simplelru provides simple LRU implementation based on build-in container/list.
Package simplelru provides simple LRU implementation based on build-in container/list.

Jump to

Keyboard shortcuts

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