goredis

package module
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 12 Imported by: 1

README

GoZix GoRedis

License Documentation

Release Build Status Go Report Card Code Coverage

The bundle provide a GoRedis integration to GoZix application.

Installation

go get github.com/gozix/goredis/v4

Dependencies

Configuration example

{
  "redis": {
    "default": {
      "host": "127.0.0.1",
      "port": "6379",
      "db": 0,
      "username": "someuser",
      "password": "somepassword",
      "max_retiries": 2,
      "read_timeout": "2s",
      "write_timeout": "2s",
      "idle_timeout": "1m"
    }
  }
}

"username" field is optional and ignored if empty "password" field is optional and ignored if empty "db" field is optional. Default is 0

Documentation

You can find documentation on pkg.go.dev and read source code if needed.

Questions

If you have any questions, feel free to create an issue.

Documentation

Overview

Package goredis provides implementation of go-redis client.

Index

Constants

View Source
const BundleName = "redis"

BundleName is default definition name.

View Source
const (
	// DEFAULT is default connection name.
	DEFAULT = "default"
)

Variables

View Source
var (
	// ErrUnknownConnection is error triggered when connection with provided name not founded.
	ErrUnknownConnection = errors.New("unknown connection")
)

Functions

This section is empty.

Types

type Bundle

type Bundle struct{}

Bundle implements the glue.Bundle interface.

func NewBundle

func NewBundle() *Bundle

NewBundle create bundle instance.

func (*Bundle) Build

func (b *Bundle) Build(builder di.Builder) error

Build implements the glue.Bundle interface.

func (*Bundle) DependsOn

func (b *Bundle) DependsOn() []string

DependsOn implements the glue.DependsOn interface.

func (*Bundle) Name

func (b *Bundle) Name() string

Name implements the glue.Bundle interface.

type Config

type Config struct {
	Host         string        `json:"host"`
	Port         string        `json:"port"`
	DB           int           `json:"db"`
	Username     string        `json:"username"`
	Password     string        `json:"password"`
	MaxRetries   int           `json:"max_retries"`
	IdleTimeout  time.Duration `json:"idle_timeout"`
	ReadTimeout  time.Duration `json:"read_timeout"`
	WriteTimeout time.Duration `json:"write_timeout"`
}

Config is registry configuration item.

type Configs

type Configs map[string]Config

Configs is registry configurations.

type Registry

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

Registry is database connection registry.

func NewRegistry

func NewRegistry(conf Configs) *Registry

NewRegistry is registry constructor.

func (*Registry) Close

func (r *Registry) Close() (err error)

Close is method for close connections.

func (*Registry) Connection

func (r *Registry) Connection() (*redis.Client, error)

Connection is default connection getter.

func (*Registry) ConnectionWithName

func (r *Registry) ConnectionWithName(name string) (_ *redis.Client, err error)

ConnectionWithName is connection getter by name.

Jump to

Keyboard shortcuts

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