cache

package
v1.19.47 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseCache added in v1.19.41

func CloseCache()

Types

type Cache added in v1.1.15

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

type DiskCache added in v1.19.42

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

func (*DiskCache) Add added in v1.19.42

func (d *DiskCache) Add(key any, value any, lifeSpan time.Duration)

func (*DiskCache) Clear added in v1.19.42

func (d *DiskCache) Clear() bool

func (*DiskCache) Close added in v1.19.42

func (d *DiskCache) Close()

func (*DiskCache) Delete added in v1.19.42

func (d *DiskCache) Delete(key any)

func (*DiskCache) Get added in v1.19.42

func (d *DiskCache) Get(key any) (any, bool)

func (*DiskCache) IsExist added in v1.19.42

func (d *DiskCache) IsExist(key any) bool

func (*DiskCache) Range added in v1.19.42

func (d *DiskCache) Range(f func(key, value any) bool)

func (*DiskCache) Set added in v1.19.42

func (d *DiskCache) Set(key any, value any, duration time.Duration)

func (*DiskCache) Value added in v1.19.42

func (d *DiskCache) Value(key any) (any, bool)

type ICache added in v1.19.42

type ICache interface {
	Add(key any, value any, lifeSpan time.Duration)
	Value(key any) (any, bool)
	IsExist(key any) bool
	Clear() bool
	Get(key any) (any, bool)
	Set(key any, value any, duration time.Duration)
	Range(f func(key, value any) bool)
	Delete(key any)
	Close()
}

func OnDiskCache added in v1.19.41

func OnDiskCache(cachePath string) ICache

func OnGetCache

func OnGetCache(cachename string, persistent ...bool) ICache

初始化一个cache cachename 缓存名字

func OnMemCache added in v1.19.42

func OnMemCache(cachename string) ICache

type MemCache added in v1.19.42

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

func New added in v1.1.15

func New(cleaningInterval time.Duration) *MemCache

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

func (*MemCache) Add added in v1.19.42

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

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

func (*MemCache) Clear added in v1.19.42

func (c *MemCache) Clear() bool

清空表內容

func (*MemCache) Close added in v1.19.42

func (cache *MemCache) Close()

Close closes the cache and frees up resources.

func (*MemCache) Delete added in v1.19.42

func (cache *MemCache) Delete(key any)

Delete deletes the key and its value from the cache.

func (*MemCache) Get added in v1.19.42

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

Get gets the value for the given key.

func (*MemCache) IsExist added in v1.19.42

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

判断key是否存在

func (*MemCache) Range added in v1.19.42

func (cache *MemCache) 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 (*MemCache) Set added in v1.19.42

func (cache *MemCache) 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 (*MemCache) Value added in v1.19.42

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

Jump to

Keyboard shortcuts

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