redis

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IClient

type IClient interface {
	redis.Cmdable
	Init(...Option) error
	Start() error
	UnInit() error
	IsValid() bool
}

IClient redis 客户端接口包装,统一 client 和 cluster client 便于使用

func NewClient

func NewClient(opts ...Option) IClient

func NewClusterClient

func NewClusterClient(opts ...Option) IClient

type Option

type Option func(o *Options)

func WithAuth

func WithAuth(passwd string) Option

WithAuth 设置鉴权信息

func WithDict

func WithDict(cfg map[string]interface{}) Option

WithDict 从字典中设置配置到Options

func WithHostNode

func WithHostNode(hosts ...string) Option

WithHostNode 追加节点到配置

type Options

type Options struct {
	// AddrHosts 集群节点 非集群模式配置一个 集群模式为一组, ip:port
	AddrHosts []string `yaml:"addr_hosts"`
	//UserName 鉴权使用的用户名
	UserName string `yaml:"user_name"`
	//Password 鉴权
	Password string `yaml:"password"`
	// DB 控制选择的数据库 默认 0
	DB int `yaml:"db"`
	// PoolSize 控制与redis 连接的最大连接数 默认为10
	PoolSize int `yaml:"pool_size"`
	// ReadOnly slave 节点启用 read-only 命令 集群模式生效
	ReadOnly bool `yaml:"read_only"`
}

Options redis 配置

Jump to

Keyboard shortcuts

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