goredis

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 4 Imported by: 0

README

goredis

在 [go-redis]github.com/go-redis/redis 基础上封装的库。


使用示例

	redisCli, err := goredis.Init(config.Get().RedisURL, goredis.WithEnableTrace())
	if err != nil {
		panic("goredis.Init error: " + err.Error())
	}

官方文档 https://redis.uptrace.dev/guide/

Documentation

Index

Constants

View Source
const (
	// ErrRedisNotFound not exist in redis
	ErrRedisNotFound = redis.Nil
	// DefaultRedisName default redis name
	DefaultRedisName = "default"
)

Variables

This section is empty.

Functions

func Init

func Init(dsn string, opts ...Option) (*redis.Client, error)

Init 连接redis dsn 支持格式: 没有密码,没有db:localhost:6379 有密码,有db:<user>:<pass>@localhost:6379/2

func Init2 added in v1.4.0

func Init2(addr string, password string, db int, opts ...Option) *redis.Client

Init2 连接redis

Types

type Option

type Option func(*options)

Option set the redis options.

func WithDialTimeout added in v1.4.0

func WithDialTimeout(t time.Duration) Option

WithDialTimeout set dail timeout

func WithEnableTrace

func WithEnableTrace() Option

WithEnableTrace use trace

func WithReadTimeout added in v1.4.0

func WithReadTimeout(t time.Duration) Option

WithReadTimeout set read timeout

func WithWriteTimeout added in v1.4.0

func WithWriteTimeout(t time.Duration) Option

WithWriteTimeout set write timeout

Jump to

Keyboard shortcuts

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