infraredis

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionConfig

type ConnectionConfig struct {
	// Whether the connection is enabled.
	// If not set, the connection is considered enabled.
	// If set to false, the program must not try to connect to this Redis instance.
	Enabled *bool `mapstructure:"enabled"`

	// Whether to use cluster client or single node client
	ClusterMode bool `mapstructure:"cluster_mode"`

	// Database Address.
	// if ClusterMode == false then "host:port" is expected
	// if ClusterMode == true  then "host:port[,host:port]" is expected
	Address string `mapstructure:"address"`

	// Read and write timeouts. Default values using getters: -1 (no timeout)
	ReadTimeout  *time.Duration `mapstructure:"read_timeout"`
	WriteTimeout *time.Duration `mapstructure:"write_timeout"`
}

func (*ConnectionConfig) GetEnabled added in v1.7.3

func (c *ConnectionConfig) GetEnabled() bool

func (*ConnectionConfig) GetReadTimeout

func (c *ConnectionConfig) GetReadTimeout() time.Duration

func (*ConnectionConfig) GetWriteTimeout

func (c *ConnectionConfig) GetWriteTimeout() time.Duration

func (*ConnectionConfig) Validate

func (c *ConnectionConfig) Validate() error

type ConnectionsConfig

type ConnectionsConfig map[string]*ConnectionConfig

func (*ConnectionsConfig) Validate

func (c *ConnectionsConfig) Validate() error

type Container

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

Container is a simple container for holding named redis connections.

func Init added in v1.11.0

func Init(wg *sync.WaitGroup, cfg ConnectionsConfig) *Container

Init creates a container and connects every enabled connection from the config in background. The caller must wait on the wait group before using the returned container. Connection failures are fatal.

func NewContainer

func NewContainer() *Container

func (*Container) Connect

func (cont *Container) Connect(name string, cfg *ConnectionConfig) error

Connect creates a new named redis connection

func (*Container) Get

func (cont *Container) Get(name string) redis.UniversalClient

Get gets connection from a container

Jump to

Keyboard shortcuts

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