goredis

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 4 Imported by: 0

README

goredis

A library wrapped on top of go-redis.


Example of use

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

Official Documents 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 connecting to redis dsn supported formats. no password, no db: localhost:6379 with password and db: <user>:<pass>@localhost:6379/2

func Init2

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

Init2 connecting to redis

Types

type Option

type Option func(*options)

Option set the redis options.

func WithDialTimeout

func WithDialTimeout(t time.Duration) Option

WithDialTimeout set dail timeout

func WithEnableTrace

func WithEnableTrace() Option

WithEnableTrace use trace

func WithReadTimeout

func WithReadTimeout(t time.Duration) Option

WithReadTimeout set read timeout

func WithWriteTimeout

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