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 ¶
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