redis

package
v0.0.0-...-15bed1d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFound

func NotFound(err error) bool

Types

type Hook

type Hook struct {
}

func NewHook

func NewHook() *Hook

func (*Hook) AfterProcess

func (h *Hook) AfterProcess(ctx context.Context, cmd redis.Cmder) error

func (*Hook) AfterProcessPipeline

func (h *Hook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error

func (*Hook) BeforeProcess

func (h *Hook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error)

func (*Hook) BeforeProcessPipeline

func (h *Hook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error)

type IRedisSet

type IRedisSet interface {
	Get(name string) RedisClient
}

type Option

type Option struct {
	Enable       bool   `default:"true" desc:"是否启用"`
	Name         string `default:"master" desc:"redis key前缀,不能重复"`
	ReadOnly     bool   `default:"false" desc:"read only"`
	Addr         string `default:"127.0.0.1:6379" desc:"redis地址"`
	DB           int    `default:"0" desc:"redis数据库"`
	Username     string `default:"" desc:"redis用户名"`
	Password     string `default:"" desc:"redis密码"`
	PoolSize     int    `default:"64" desc:"poolSize * runtime.GOMAXPROCS"`
	PingInternal int    `default:"30" desc:"ping间隔"`
}

func (*Option) Connect

func (opt *Option) Connect(ctx context.Context) (db RedisClient)

Connect 单节点

type Options

type Options []Option

func (Options) Connects

func (opts Options) Connects(ctx context.Context) (dbs IRedisSet)

type RedisClient

type RedisClient interface {
	Ping(ctx context.Context) error
	DBSize(ctx context.Context) (int64, error)
	SetNX(ctx context.Context, key string, value string, expiration time.Duration) (bool, error)
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key string, value string, expiration time.Duration) error
	Del(ctx context.Context, key string) (int64, error)
	Expire(ctx context.Context, key string, duration time.Duration) (bool, error)
	Exists(ctx context.Context, key string) (int64, error)
	HSet(ctx context.Context, key string, field string, value string) error
	HGet(ctx context.Context, key string, field string) (string, error)
	HGetAll(ctx context.Context, key string) (map[string]string, error)
	HMGets(ctx context.Context, key string, fields ...string) ([]interface{}, error)
	HMSet(ctx context.Context, key string, fields map[string]interface{}) error
	HExists(ctx context.Context, key string, field string) (bool, error)
	HKeys(ctx context.Context, key string) ([]string, error)
	HVals(ctx context.Context, key string) ([]string, error)
	HIncrBy(ctx context.Context, key string, field string, value int64) (int64, error)
	HIncrByFloat(ctx context.Context, key string, field string, value float64) (float64, error)
	HSetNX(ctx context.Context, key string, field string, value string) (bool, error)
	Info(ctx context.Context, section string) (string, error)
	SetPrefix(prefix string) RedisClient // 设置key前缀; 不要重复设置
	SetSep(sep string) RedisClient       // 设置分隔符 默认":"
}

func GetRedisInstance

func GetRedisInstance(name string) RedisClient

func NewRedisClient

func NewRedisClient(opt *redis.Options) RedisClient

Directories

Path Synopsis
Package db is a generated GoMock package.
Package db is a generated GoMock package.

Jump to

Keyboard shortcuts

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