redis

package
v0.0.0-...-7408474 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 4 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 {
	// URL is used to connect to Redis.
	URL string

	// LongPollTimeout is the timeout in seconds for the BRPOP Redis command that reads from the queues. Zero means no
	// timeout, but it is better that you set a value, because it also has the effect of pinging the connection, to make
	// sure it is still active.
	LongPollTimeout int

	// MaxIdle is a parameter for redis.Pool.
	MaxIdle int

	// MaxActive is a parameter for redis.Pool.
	MaxActive int

	// IdleTimeout is a parameter for redis.Pool.
	IdleTimeout time.Duration

	// ReadTimeout is a parameter for redis.DialReadTimeout.
	ReadTimeout time.Duration

	// WriteTimeout is a parameter for redis.DialWriteTimeout.
	WriteTimeout time.Duration
}

Config holds the configuration for Redis connections.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns the default configuration.

type ConnManager

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

ConnManager implements the ConnProvider interface and encapsulates the process of establishing and configuring Redis connections. The non-dedicated connections use redis.Pool.

func NewConnManager

func NewConnManager(cfg *Config) *ConnManager

NewConnManager returns a new instance. Make sure to call Close when you are done.

func (*ConnManager) Close

func (cm *ConnManager) Close() error

Close releases resources used by the connection pool.

func (*ConnManager) Conn

func (cm *ConnManager) Conn(ctx context.Context) (redis.Conn, error)

Conn implements ConnProvider. It returns connections from a shared pool.

func (*ConnManager) DialLongPoll

func (cm *ConnManager) DialLongPoll(ctx context.Context) (redis.Conn, error)

DialLongPoll implements ConnProvider.

Jump to

Keyboard shortcuts

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