cache

package
v0.0.0-...-7bf0052 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCache

type BaseCache struct {
	CacheName    string
	KvStoreItems sync.Map
}

创建一个缓存库模型

func NewCache

func NewCache(cacheName string) *BaseCache

func (*BaseCache) ClearExpireData

func (baseCache *BaseCache) ClearExpireData() bool

清除过期数据

func (*BaseCache) Count

func (baseCache *BaseCache) Count() int

返回缓存中数据项的数量

func (*BaseCache) Delete

func (baseCache *BaseCache) Delete(key interface{}) bool

删除一条内容

func (*BaseCache) Exists

func (baseCache *BaseCache) Exists(key interface{}) bool

判断一个key是否存在

func (*BaseCache) Expire

func (baseCache *BaseCache) Expire(key interface{}, lifeTime time.Duration) bool

给一个key设置(或更新)过期 返回否 代表这个key的内容不存在 正 代表成功

func (*BaseCache) Flush

func (baseCache *BaseCache) Flush() bool

刷新服务器上保存的内容 清空缓存

func (*BaseCache) Get

func (baseCache *BaseCache) Get(key interface{}) (interface{}, bool)

获取一条内容

func (*BaseCache) GetKvStore

func (baseCache *BaseCache) GetKvStore(key interface{}) (interface{}, bool)

获取一条内容

func (*BaseCache) GetKvStoreSlice

func (baseCache *BaseCache) GetKvStoreSlice() []*KvStore

遍历集合

func (*BaseCache) LoadFromFile

func (baseCache *BaseCache) LoadFromFile(filename string) error

从文件中读取序列化的数据

func (*BaseCache) LoadIoReader

func (baseCache *BaseCache) LoadIoReader(r io.Reader) error

从io.Reader读取

func (*BaseCache) SaveIoWriter

func (baseCache *BaseCache) SaveIoWriter(w io.Writer) (err error)

将缓存数据写入io.Writer中

func (*BaseCache) SaveToFile

func (baseCache *BaseCache) SaveToFile(folder, filename string) error

将内存数据序列化到文件

func (*BaseCache) Set

func (baseCache *BaseCache) Set(key interface{}, value interface{}, lifeTime time.Duration) bool

增加一条内容

type KvStore

type KvStore struct {
	Key        interface{}
	Value      interface{}
	LifeTime   time.Duration
	CreateTime time.Time
}

创建key/value模型

func (*KvStore) IsExpired

func (kvstore *KvStore) IsExpired() bool

检验是否过期

Jump to

Keyboard shortcuts

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