goredis

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 4 Imported by: 0

README

goredis

goredis library wrapped in 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

Overview

Package goredis is a library wrapped on top of github.com/go-redis/redis.

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