cache

package
v1.1.21 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 3 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 interface{}, value interface{}, 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 interface{})

Delete deletes the key and its value from the cache.

func (*Cache) Get added in v1.1.15

func (cache *Cache) Get(key interface{}) (interface{}, bool)

Get gets the value for the given key.

func (*Cache) IsExist added in v1.1.15

func (c *Cache) IsExist(key interface{}) bool

判断key是否存在

func (*Cache) Range added in v1.1.15

func (cache *Cache) Range(f func(key, value interface{}) 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 interface{}, value interface{}, 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 interface{}) (interface{}, 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