cache

package
v0.0.0-...-de87630 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(cacheSwitch string)

Init 初始化全局cache

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}
var (
	RedisAddr = "0.0.0.0:123"

	GlobalCache *Cache // 全局缓存
)

func (*Cache) Contains

func (c *Cache) Contains(key string) bool

Contains 检测缓存中是否存在对应的键值对

func (*Cache) Delete

func (c *Cache) Delete(Key string) error

Delete 删除缓存中的键值对

func (*Cache) DeleteMulti

func (c *Cache) DeleteMulti(keys []string) error

DeleteMulti 批量删除键值对

func (*Cache) Fetch

func (c *Cache) Fetch(key string) (string, error)

Fetch 获取缓存中的键值对

func (*Cache) FetchMulti

func (c *Cache) FetchMulti(keys []string) map[string]string

FetchMulti 批量获取缓存中的键值对

func (*Cache) Flush

func (c *Cache) Flush() error

Flush 清空缓存

func (*Cache) Save

func (c *Cache) Save(key, value string) error

Save 保存键值对到缓存中

func (*Cache) SaveByTime

func (c *Cache) SaveByTime(key, value string, lifeTime time.Duration) error

SaveByTime 按照自定义时间保存键值对到缓存中

func (*Cache) SaveMulti

func (c *Cache) SaveMulti(kvs map[string]string) error

SaveMulti 批量保存键值对到缓存中

func (*Cache) SaveMultiByTime

func (c *Cache) SaveMultiByTime(kvs map[string]string, lifeTime time.Duration) error

SaveMulti 按照自定义时间批量保存键值对到缓存中

Jump to

Keyboard shortcuts

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