db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URI            string `json:"uri"`
	DB             int    `json:"db"`
	MaxIdle        int    `json:"max_idle"`
	MaxActive      int    `json:"max_active"`
	IdleTimeout    int    `json:"idle_timeout"`
	ConnectTimeout int    `json:"connection_timeout"`
}

Config is a configuration for the redis pool

func (*Config) Defaults

func (r *Config) Defaults()

Defaults sets the redis connection defaults.

type Conn

type Conn redis.Conn

Conn represents a redis connection

type Pool

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

Pool represents a redis pool

func NewPool

func NewPool(config *Config) *Pool

NewPool creates new redis pool with the given configuration.

func (*Pool) Close

func (r *Pool) Close() error

Close closes the redis pool

func (*Pool) Conn

func (r *Pool) Conn() (Conn, error)

Conn returns a new redis connection. Caller must close the connection. Before returning the connection is tested and if it's not alive - an error is returned.

type Pooler

type Pooler interface {
	Conn() (Conn, error)
	Close() error
}

Pooler is a redis pool interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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