redis

package
v0.0.0-...-6fafc3c Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package redis provides an abstraction for handling redis connection logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	Connect() redis.Conn
	PingConnect() (redis.Conn, error)
}

Connector is an interface type which describes methods for retrieving a redis connection

type RedisConfig

type RedisConfig struct {
	Host           string
	Password       string
	Port           int
	MaxIdleConns   int
	MaxActiveConns int
	IdleTimeout    time.Duration
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
}

RedisConfig is a struct type which holds redis connector pool configurations

func (*RedisConfig) Address

func (rc *RedisConfig) Address() string

Address returns redis connection string

type RedisConnector

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

RedisConnector is a struct type which implements a Connector interface

RedisConnector can hold multiple redis connection pools this provides a possibility to operate with multiple redis slave from one connector

func NewRedisConnector

func NewRedisConnector(cfgs []RedisConfig) (*RedisConnector, error)

NewRedisConnector inits and returns a pointer to RedisConnector instance

func (*RedisConnector) Connect

func (c *RedisConnector) Connect() redis.Conn

Connect returns an awailable redis connection from a random pool. If connection is by any reason broken, error will be returned on first attempt to use the connection In cases when it's needed to check if the connection is alive, use PingConnect method

func (*RedisConnector) PingConnect

func (c *RedisConnector) PingConnect() (redis.Conn, error)

PingConnect returns an awailable redis connection from a random pool. Second arguments is an error generated by a "PING" method sent to a retrieved connection

Jump to

Keyboard shortcuts

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