cache

package
v1.0.84 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GFileCacheDir = ""

Functions

func Register

func Register(name string, driver IFactoryCache)

注册Cache到注册器中

func ToStruct

func ToStruct(in, out interface{}) error

interface 重新解析到对象

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{}
	GetStruct(key string, out interface{}) error
	Del(keys ...string) bool
	Close()
	Clear()
}

func Factory

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

生成一个Cache执行实例

type ErrNotExists

type ErrNotExists struct {
}

func (ErrNotExists) Error

func (e ErrNotExists) Error() string

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) Close

func (self *FileCacheSt) Close()

清理内存缓存记录

func (*FileCacheSt) Del

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

删除缓存记录信息

func (*FileCacheSt) Get

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

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

func (*FileCacheSt) GetStruct

func (self *FileCacheSt) GetStruct(key string, out interface{}) error

直接获取数据并解析到结构当中

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) Close

func (self *MemoryCacheSt) Close()

清理内存缓存记录

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) GetStruct

func (self *MemoryCacheSt) GetStruct(key string, out interface{}) error

直接获取数据并解析到结构当中

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) Close

func (self *RedisCacheSt) Close()

清理关闭连接处理逻辑

func (*RedisCacheSt) Del

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

删除缓存记录信息

func (*RedisCacheSt) Get

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

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

func (*RedisCacheSt) GetStruct

func (self *RedisCacheSt) GetStruct(key string, out interface{}) error

直接获取数据并解析到结构当中

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