redis

package
v0.0.0-...-1e877d2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 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) ClearAll

func (c *Cache) ClearAll() error

ClearAll todo

func (*Cache) Close

func (c *Cache) Close() error

Close todo

func (*Cache) Decr

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

Decr todo

func (*Cache) Delete

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

Delete todo

func (*Cache) Get

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

Get todo

func (*Cache) Incr

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

Incr todo

func (*Cache) IsExist

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

IsExist todo

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 todo

func (*Cache) PutWithTTL

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

PutWithTTL todo

func (*Cache) SetDefaultTTL

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

SetDefaultTTL todo

func (*Cache) WithContext

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

WithContext 启用上下文, 方便trace

type Config

type Config struct {
	Prefix     string `json:"prefix,omitempty" yaml:"prefix" toml:"prefix" env:"MCUBE_CACHE_PREFIX"`
	Address    string `json:"address,omitempty" yaml:"address" toml:"address" env:"MCUBE_CACHE_ADDRESS"`
	DB         int    `json:"db,omitempty" yaml:"db" toml:"db" env:"MCUBE_CACHE_DB"`
	Password   string `json:"password,omitempty" yaml:"password" toml:"password" env:"MCUBE_CACHE_PASSWORD"`
	DefaultTTL int    `json:"default_ttl,omitempty" yaml:"default_ttl" toml:"default_ttl" env:"MCUBE_CACHE_TTL"`
}

Config 配置

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig 默认配置

Jump to

Keyboard shortcuts

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