XGocache

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGocache

func CheckGocache() bool

检查连接池实例

func CreateDefaultCache

func CreateDefaultCache(config *Config)

创建一个默认配置的DB

func CreateDefaultCacheFrom

func CreateDefaultCacheFrom(config *Config) error

创建一个默认配置的DB

func DumpItems

func DumpItems(cfg *Config) error

导出所有缓存keys,以便临时保存到文件或其他存储服务

func NewCache

func NewCache(cfg *Config) *cache.Cache

func NewCacheForm

func NewCacheForm(cfg *Config) (*cache.Cache, error)

从文件读取

func NewStarter

func NewStarter() *starter

func X

func X() *cache.Cache

func XF

func XF(f func(c *cache.Cache) error) error

资源组件闭包执行

Types

type CommonGocache added in v1.1.5

type CommonGocache struct{}

func NewCommonGocache added in v1.1.5

func NewCommonGocache() *CommonGocache

func (*CommonGocache) Add added in v1.1.5

func (*CommonGocache) Add(k string, v interface{}) error

添加一个不存在或已超时的键值

func (*CommonGocache) AddWithExp added in v1.1.5

func (*CommonGocache) AddWithExp(k string, v interface{}, exp time.Duration) error

添加一个不存在或已超时的键值,带超时,单位s

func (*CommonGocache) Decrement added in v1.1.5

func (*CommonGocache) Decrement(k string, v int64) error

自减int64

func (*CommonGocache) Delete added in v1.1.5

func (*CommonGocache) Delete(k string) bool

删除键值

func (*CommonGocache) Get added in v1.1.5

func (*CommonGocache) Get(k string) (interface{}, bool)

获取一个键值

func (*CommonGocache) GetWithExp added in v1.1.5

func (*CommonGocache) GetWithExp(k string) (interface{}, time.Time, bool)

获取一个带过期时间的键值

func (*CommonGocache) Increment added in v1.1.5

func (*CommonGocache) Increment(k string, v int64) error

自增int64

func (*CommonGocache) Replace added in v1.1.5

func (*CommonGocache) Replace(k string, v interface{}) error

更新一个已存在且未过期的键值,不满足条件则报错

func (*CommonGocache) ReplaceWithExp added in v1.1.5

func (*CommonGocache) ReplaceWithExp(k string, v interface{}, exp time.Duration) error

更新一个已存在且未过期的键值,不满足条件则报错,带超时,单位s

func (*CommonGocache) Set added in v1.1.5

func (*CommonGocache) Set(k string, v interface{}) error

更新或添加一个键值,无论是否已存在

func (*CommonGocache) SetWithExp added in v1.1.5

func (*CommonGocache) SetWithExp(k string, v interface{}, exp time.Duration) error

更新或添加一个键值,无论是否已存在,带超时,单位s

type Config

type Config struct {
	DefaultExpiration time.Duration // 默认超时时间,小于1则长期有效
	CleanupInterval   time.Duration // 内存清理间隔时间,小于1则长期有效
	DumpFileName      string        // 缓存keys导出文件位置,停机时自动备份
}

func DefaultConfig

func DefaultConfig() *Config

Jump to

Keyboard shortcuts

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