redis

package
v0.0.0-...-bf04ae1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 7 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) Clear

func (c *Cache) Clear() error

Clear 清除所有数据(redis).

func (*Cache) Close

func (c *Cache) Close() error

Close 关闭缓存(redis).

func (*Cache) Decr

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

Decr 按键减少缓存的int值,作为计数器(redis).

func (*Cache) Delete

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

Delete 删除指定Key指定的Value(redis).

func (*Cache) Get

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

Get 返回Kev=>Value(redis).

func (*Cache) Incr

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

Incr 按键增加缓存的int值,作为计数器(redis).

func (*Cache) IsExist

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

IsExist 检测指定Key的Value是否存在(redis).

func (*Cache) ListKey

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

ListKey 根据缓存Request返回缓存中的Response(redis).

func (*Cache) Put

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

Put 推送Key=>Value使用默认TTL时间戳(redis).

func (*Cache) PutWithTTL

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

PutWithTTL 推送Kev => Value 并设置TTL时间戳(redis).

func (*Cache) SetDefaultTTL

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

SetDefaultTTL 设置默认TTL时间戳(redis).

func (*Cache) WithContext

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

WithContext 启用上下文, 方便trace(redis).

type Config

type Config struct {
	Prefix     string `json:"prefix,omitempty" yaml:"prefix" toml:"prefix" env:"GLACIER_DEVOPS_CACHE_PREFIX"`
	Address    string `json:"address,omitempty" yaml:"address" toml:"address" env:"GLACIER_DEVOPS_CACHE_ADDRESS"`
	DB         int    `json:"db,omitempty" yaml:"db" toml:"db" env:"GLACIER_DEVOPS_CACHE_DB"`
	Password   string `json:"password,omitempty" yaml:"password" toml:"password" env:"GLACIER_DEVOPS_CACHE_PASSWORD"`
	DefaultTTL int    `json:"default_ttl,omitempty" yaml:"default_ttl" toml:"default_ttl" env:"GLACIER_DEVOPS_CACHE_TTL"`
}

func NewDefaultConfig

func NewDefaultConfig() *Config

Jump to

Keyboard shortcuts

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