redis

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: MIT Imports: 8 Imported by: 1

README

go-redis

go-redis is a redigo wrapper that supports multi redis servers distribute using consistent hashing by key.

license

Installation

$ go get -u github.com/gjbae1212/go-redis

LICENSE

This project is following The MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	sync.RWMutex
	Opt   *Option
	Ring  *consistent.Consistent
	Pools map[string]*Pool
}

func (*Group) Close

func (c *Group) Close() error

Close closes redis.

func (*Group) Do

func (c *Group) Do(command string, args ...interface{}) (interface{}, error)

Do calls command.

func (*Group) DoWithTimeout

func (c *Group) DoWithTimeout(timeout time.Duration, command string, args ...interface{}) (interface{}, error)

DoWithTimeout calls command with timeout.

func (*Group) Stats

func (c *Group) Stats() (map[string]redigo.PoolStats, error)

Stats gets server status.

type Manager

type Manager interface {
	Do(command string, args ...interface{}) (interface{}, error)
	DoWithTimeout(timeout time.Duration, command string, args ...interface{}) (interface{}, error)
	Close() error
	Stats() (map[string]redigo.PoolStats, error)
}

func NewManager

func NewManager(addrs []string) (Manager, error)

NewManager creates an object implemented Manager interface.

type Option

type Option struct {
	Idle            int           // max idle connection count
	Active          int           // max active connection count
	IdleTimeout     time.Duration // connection will remain for this duration
	ConnTimeout     time.Duration // tcp handshake timeout
	ReadTimeout     time.Duration // request read timeout
	WriteTimeout    time.Duration // read and response timeout
	MaxConnLifetime time.Duration // per connection max alive duration
	Wait            bool          // if pool is overflow at max active limit, whether wait
}

type Pool

type Pool struct {
	*redigo.Pool
	Addr string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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