redis

package
v0.0.0-...-05d1b2a Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

Example

func main() {
	openTelemetry.Register(jaeger.Jaeger(
		openTelemetry.ServiceName("go-redis"),
		openTelemetry.TraceUrl("http://localhost:14268/api/traces"),
	))
	defer openTelemetry.Shutdown(jaeger.Jaeger())

	if err := Connect(); err != nil {
		panic(err)
	}
	defer Close()

	ctx := context.Background()
	tracer := openTelemetry.Tracer()
	ctx, span := tracer.Start(ctx, "go-redis")
	defer span.End()

	cli := GetClient()
	cli.Get(ctx, "key")
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultName = "default"
)

Functions

func Close

func Close()

func Connect

func Connect(opts ...Option) error

func GetClient

func GetClient(name ...string) *goRedis.Client

Types

type Config

type Config struct {
	Redis []Options `json:"redis"`
}

func (Config) Close

func (c Config) Close() error

func (Config) Init

func (c Config) Init() error

type Option

type Option func(*Options)

func Addr

func Addr(addr string) Option

func DB

func DB(num int) Option

func DialTimeout

func DialTimeout(timeout time.Duration) Option

func MaxRetries

func MaxRetries(max int) Option

func Metrics

func Metrics(b bool) Option

func Name

func Name(name string) Option

func Password

func Password(password string) Option

func PoolSize

func PoolSize(size int) Option

func PoolTimeout

func PoolTimeout(timeout time.Duration) Option

func ReadTimeout

func ReadTimeout(timeout time.Duration) Option

func Trace

func Trace(b bool) Option

func Username

func Username(username string) Option

func WriteTimeout

func WriteTimeout(timeout time.Duration) Option

type Options

type Options struct {
	Name         string `json:"name" mapstructure:"name"`
	Addr         string `json:"addr" mapstructure:"addr"`
	Username     string `json:"username" mapstructure:"username"`
	Password     string `json:"password" mapstructure:"password"`
	DB           int    `json:"db" mapstructure:"db"`
	MaxRetries   int    `json:"max_retries" mapstructure:"max_retries"`
	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	PoolSize     int
	PoolTimeout  time.Duration
	Trace        bool
	Metrics      bool
}

func GetConfig

func GetConfig(name ...string) Options

Jump to

Keyboard shortcuts

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