redis

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Zlib Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTlsFunc = func(cnf *config.RedisConfig) (*tls.Config, error) {
	if strings.EqualFold(cnf.Tls.Key, "false") {
		return nil, result.RErrNotSupport
	}
	if strings.EqualFold(cnf.Tls.Key, "true") {
		return &tls.Config{}, nil
	}
	if strings.EqualFold(cnf.Tls.Key, "skip-verify") ||
		strings.EqualFold(cnf.Tls.Key, "preferred") {
		return &tls.Config{InsecureSkipVerify: true}, nil
	}
	cert, rootCertPool, err := commontls.GetCertificate(&cnf.Tls)
	if err != nil {
		return nil, err
	}
	return &tls.Config{
		RootCAs:      rootCertPool,
		Certificates: []tls.Certificate{cert},
	}, nil
}

Functions

func UseTls added in v1.9.15

func UseTls(cnf *config.RedisConfig, opts ...option.Option) (*tls.Config, error)

func WithTlsOption added in v1.9.15

func WithTlsOption(f func(cnf *config.RedisConfig) (*tls.Config, error)) option.Option

Types

type Adapter added in v1.1.23

type Adapter struct {
	// contains filtered or unexported fields
}

func NewAdapter added in v1.1.23

func NewAdapter(name string, cfg *config.RedisConfig, sentinelCfg *config.RedisConfig, clusterCfg *config.RedisConfig, opts ...option.Option) (*Adapter, error)

func (*Adapter) Cluster added in v1.1.23

func (a *Adapter) Cluster() *redis.ClusterClient

func (*Adapter) Name added in v1.1.23

func (a *Adapter) Name() string

func (*Adapter) Rds added in v1.1.23

func (a *Adapter) Rds() *redis.Client

func (*Adapter) Sentinel added in v1.1.23

func (a *Adapter) Sentinel() *redis.SentinelClient

type Client

type Client interface {
	Get(name string) (Redis, error)
	Close(name string) error
	CloseAll()
	Select(name string)                    //选哪个redis
	SelectDB(name string, index int) error //选哪个redis db
}

func NewRedis

func NewRedis(conf []config.Redis, opts ...option.Option) (Client, error)

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func (*Connector) Close

func (c *Connector) Close(name string) error

func (*Connector) CloseAll

func (c *Connector) CloseAll()

func (*Connector) Get

func (c *Connector) Get(name string) (Redis, error)

func (*Connector) Select added in v0.4.1

func (c *Connector) Select(name string)

func (*Connector) SelectDB added in v0.4.6

func (c *Connector) SelectDB(name string, index int) error

type Logger added in v1.1.23

type Logger struct {
	config.RedisLogger
}

func (*Logger) Printf added in v1.1.23

func (l *Logger) Printf(ctx context.Context, format string, v ...interface{})

type Redis added in v1.1.23

type Redis interface {
	Rds() *redis.Client
	Sentinel() *redis.SentinelClient
	Cluster() *redis.ClusterClient
	Name() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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