cache

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MulanPSL-2.0 Imports: 5 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[TYPE any] struct {
	mutexs.Mutex
	// contains filtered or unexported fields
}

索引信息不能变,不能重复

func New

func New[TYPE any]() (cache *Cache[TYPE])

依照temp类型创建一个过期时间为lifetime容器存储存储TYPE.lifetime为0永不过期. 示例 devices = New[debvice.Deveice](nil *device.kxb, 0)

func (*Cache[TYPE]) Add

func (cache *Cache[TYPE]) Add(value *TYPE)

func (*Cache[TYPE]) Delete

func (cache *Cache[TYPE]) Delete(value *TYPE)

func (*Cache[TYPE]) DeleteBy

func (cache *Cache[TYPE]) DeleteBy(keyName string, keyValue any)

func (*Cache[TYPE]) FindBy

func (cache *Cache[TYPE]) FindBy(keyName string, keyValue any) (value *TYPE, ok bool)

使用不合法的keyName会产生panic

func (*Cache[TYPE]) FindsOf

func (cache *Cache[TYPE]) FindsOf(indexName string, indexValue any) (values []*TYPE)

使用不合法的indexName会产生panic

func (*Cache[TYPE]) Reset

func (cache *Cache[TYPE]) Reset(keyName string, keyValue any, fun func(value *TYPE)) (ok bool)

使用不合法的keyName会产生panic,通过key检索到目标后,可以通过fun重置目标

func (*Cache[TYPE]) RollFor

func (cache *Cache[TYPE]) RollFor(reason string) (value *TYPE, ok bool)

type Index

type Index[TYPE any] struct {
	// contains filtered or unexported fields
}

type Key

type Key[TYPE any] struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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