cache

package module
v0.0.0-...-1bb640e Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver IFactoryCache)

注册Cache到注册器中

Types

type CacheConfigSt

type CacheConfigSt struct {
	Driver string `yaml:"driver"`
	Params string `yaml:"params"`
}

type CacheItemSt

type CacheItemSt struct {
	Expire int64       `json:"expire" bson:"expire"`
	Data   interface{} `json:"data" bson:"data"`
}

type Cacher

type Cacher interface {
	Set(key string, data interface{}, expire int64) bool
	Get(key string) interface{}
	Del(keys ...string) bool
	Clear()
}

func Factory

func Factory(name string, params interface{}) Cacher

生成一个Cache执行实例

type FactoryFileCache

type FactoryFileCache struct {
}

func (*FactoryFileCache) Open

func (factory *FactoryFileCache) Open(params interface{}) Cacher

获取缓存日志配置信息

type FactoryMemoryCache

type FactoryMemoryCache struct {
}

func (*FactoryMemoryCache) Open

func (factory *FactoryMemoryCache) Open(params interface{}) Cacher

type FactoryRedisCache

type FactoryRedisCache struct {
}

func (*FactoryRedisCache) Open

func (factory *FactoryRedisCache) Open(params interface{}) Cacher

type FileCacheSt

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

func NewFileCache

func NewFileCache(dir string, dirDept int) *FileCacheSt

初始化一个Cache实例

func (*FileCacheSt) Clear

func (self *FileCacheSt) Clear()

清理内存缓存记录

func (*FileCacheSt) Del

func (self *FileCacheSt) Del(keys ...string) bool

删除缓存记录信息

func (*FileCacheSt) Get

func (self *FileCacheSt) Get(key string) interface{}

获取一个缓存记录信息,过期记录不返回

func (*FileCacheSt) Set

func (self *FileCacheSt) Set(key string, data interface{}, expire int64) bool

设置一个缓存记录

type IFactoryCache

type IFactoryCache interface {
	Open(params interface{}) Cacher
}

type MemoryCacheSt

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

func NewMemoryCache

func NewMemoryCache(gc time.Duration) *MemoryCacheSt

初始化一个Cache实例

func (*MemoryCacheSt) Clear

func (self *MemoryCacheSt) Clear()

清理内存缓存记录

func (*MemoryCacheSt) Del

func (self *MemoryCacheSt) Del(keys ...string) bool

删除缓存记录信息

func (*MemoryCacheSt) GC

func (self *MemoryCacheSt) GC()

GC过期资源回收

func (*MemoryCacheSt) Get

func (self *MemoryCacheSt) Get(key string) interface{}

获取一个缓存记录信息,过期记录不返回

func (*MemoryCacheSt) Set

func (self *MemoryCacheSt) Set(key string, data interface{}, expire int64) bool

设置一个缓存记录

type RedisCacheSt

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

func NewRedisCache

func NewRedisCache(dsn string) *RedisCacheSt

初始化一个Cache实例

func (*RedisCacheSt) Clear

func (self *RedisCacheSt) Clear()

清理内存缓存记录

func (*RedisCacheSt) Del

func (self *RedisCacheSt) Del(keys ...string) bool

删除缓存记录信息

func (*RedisCacheSt) Get

func (self *RedisCacheSt) Get(key string) interface{}

获取一个缓存记录信息,过期记录不返回

func (*RedisCacheSt) Set

func (self *RedisCacheSt) Set(key string, data interface{}, expire int64) bool

设置一个缓存记录

Jump to

Keyboard shortcuts

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