redis

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 4 Imported by: 0

README

Introduction

Usages

Customized use case.

func main() {
    s, err := hrpc.NewServer(
		option.WithServerName("orderservice"),
		option.WithDatabases(redis.New(
            redis.WithCustomized(), // Very important, if you forget to provide this option, the HRPC will read configuration got from the configuration center to load.
            redis.WithAddress("xxxx"),
            redis.WithDB(0),
            redis.WithAuth("user", "pass"),
            redis.WithPort(6378), // Default 6379
        )),
		option.WithEnvironment(option.Development),
		option.WithHealthCheck(),
	)
    // xxx
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNil when key does not exist.
	ErrNil = redisv8.Nil
)

Functions

func Client added in v0.0.6

func Client() *redisv8.Client

Client returns the handler to operate redis if success

func Valid

func Valid() bool

Valid returns a bool valud to determine whether the connection is ready to use

Types

type Option

type Option func(o *Options)

func WithAddress added in v0.0.44

func WithAddress(s string) Option

func WithAuth added in v0.0.44

func WithAuth(username, password string) Option

func WithCustomized added in v0.0.44

func WithCustomized() Option

WithCustomized will use your own configurations. To be reminder that you should make sure the values of Address, DB, Auth, Port have been assigned correctly.

func WithDB added in v0.0.44

func WithDB(i int) Option

func WithMaxRetries added in v0.0.44

func WithMaxRetries(i int) Option

func WithPort added in v0.0.44

func WithPort(port int) Option

type Options added in v0.0.44

type Options struct {
	Address  string `json:"address"`
	DB       int    `json:"db"`
	Username string `json:"username"`
	Password string `json:"password"`
	Port     int    `json:"port"`
	Network  string `json:"network"`
	// Maximum number of retries before giving up.
	// Default is 3 retries; -1 (not 0) disables retries.
	MaxRetries int `json:"max_retries"`
	// contains filtered or unexported fields
}

type Redis

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

func New

func New(opts ...Option) *Redis

func (*Redis) Connect

func (r *Redis) Connect() error

func (*Redis) Destory

func (r *Redis) Destory()

func (*Redis) Load

func (r *Redis) Load(src []byte) error

func (Redis) Name added in v0.0.6

func (r Redis) Name() string

Jump to

Keyboard shortcuts

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