memory

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache 内存缓存

func NewCache

func NewCache(conf *Config) *Cache

NewCache new an redis cache instance

func (*Cache) ClearAll

func (c *Cache) ClearAll() error

ClearAll 清除缓存

func (*Cache) Close

func (c *Cache) Close() error

Close 关闭缓存

func (*Cache) Decr

func (c *Cache) Decr(key string) error

Decr 等待实现

func (*Cache) Delete

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

Delete 删除对象

func (*Cache) Get

func (c *Cache) Get(key string, val interface{}) error

Get 获取对象

func (*Cache) Incr

func (c *Cache) Incr(key string) error

Incr 等待实现

func (*Cache) IsExist

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

IsExist 判断Key是否存在

func (*Cache) ListKey

func (c *Cache) ListKey(req *cache.ListKeyRequest) (*cache.ListKeyResponse, error)

ListKey todo

func (*Cache) Put

func (c *Cache) Put(key string, val interface{}) error

Put 添加key

func (*Cache) PutWithTTL

func (c *Cache) PutWithTTL(key string, val interface{}, ttl time.Duration) error

PutWithTTL 指定TTL

func (*Cache) SetDefaultTTL

func (c *Cache) SetDefaultTTL(ttl time.Duration)

SetDefaultTTL 修复默认TTL

func (*Cache) WithContext

func (c *Cache) WithContext(ctx context.Context) cache.Cache

WithContext 携带上下文

type Config

type Config struct {
	TTL  int `json:"ttl,omitempty" yaml:"ttl" toml:"ttl" env:"toolbox_CACHE_TTL"` // 默认秒
	Size int `json:"size,omitempty" yaml:"size" toml:"size" env:"toolbox_CACHE_SIZE"`
}

Config 配置选项

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig 使用默认配置

func (*Config) GetTTL

func (c *Config) GetTTL() time.Duration

Jump to

Keyboard shortcuts

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