memory

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v0.3.1

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 added in v0.3.1

func (c *Cache) ClearAll() error

ClearAll 清除缓存

func (*Cache) Close added in v0.3.1

func (c *Cache) Close() error

Close 关闭缓存

func (*Cache) Decr added in v0.3.1

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

Decr 等待实现

func (*Cache) Delete added in v0.3.1

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

Delete 删除对象

func (*Cache) Get added in v0.3.1

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

Get 获取对象

func (*Cache) Incr added in v0.3.1

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

Incr 等待实现

func (*Cache) IsExist added in v0.3.1

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

IsExist 判断Key是否存在

func (*Cache) ListKey added in v0.5.1

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

ListKey todo

func (*Cache) Put added in v0.3.1

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

Put 添加key

func (*Cache) PutWithTTL added in v0.3.1

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

PutWithTTL 指定TTL

func (*Cache) SetDefaultTTL added in v0.3.1

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

SetDefaultTTL 修复默认TTL

func (*Cache) WithContext added in v0.3.2

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

WithContext 携带上下文

type Config added in v0.3.1

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

Config 配置选项

func NewDefaultConfig added in v0.3.1

func NewDefaultConfig() *Config

NewDefaultConfig 使用默认配置

func (*Config) GetTTL added in v1.4.4

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

Jump to

Keyboard shortcuts

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