cache

package
v1.19.33 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v1.1.15

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

func New added in v1.1.15

func New(cleaningInterval time.Duration) *Cache

New creates a new cache that asynchronously cleans expired entries after the given time passes.

func OnGetCache

func OnGetCache(cachename string) *Cache

初始化一个cache cachename 缓存名字

func (*Cache) Add added in v1.1.15

func (c *Cache) Add(key any, value any, lifeSpan time.Duration)

添加一个缓存 lifeSpan:缓存时间,0表示永不超时

func (*Cache) Clear added in v1.1.15

func (c *Cache) Clear() bool

清空表內容

func (*Cache) Close added in v1.1.15

func (cache *Cache) Close()

Close closes the cache and frees up resources.

func (*Cache) Delete added in v1.1.15

func (cache *Cache) Delete(key any)

Delete deletes the key and its value from the cache.

func (*Cache) Get added in v1.1.15

func (cache *Cache) Get(key any) (any, bool)

Get gets the value for the given key.

func (*Cache) IsExist added in v1.1.15

func (c *Cache) IsExist(key any) bool

判断key是否存在

func (*Cache) Range added in v1.1.15

func (cache *Cache) Range(f func(key, value any) bool)

Range calls f sequentially for each key and value present in the cache. If f returns false, range stops the iteration.

func (*Cache) Set added in v1.1.15

func (cache *Cache) Set(key any, value any, duration time.Duration)

Set sets a value for the given key with an expiration duration. If the duration is 0 or less, it will be stored forever.

func (*Cache) Value added in v1.1.15

func (c *Cache) Value(key any) (any, bool)

type MyCache

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

Jump to

Keyboard shortcuts

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