redis

package
v0.0.0-...-9ac5701 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REDIS_REPLY_STRING  = 1
	REDIS_REPLY_ARRAY   = 2
	REDIS_REPLY_INTEGER = 3
	REDIS_REPLY_NIL     = 4
	REDIS_REPLY_STATUS  = 5
	REDIS_REPLY_ERROR   = 6
)
View Source
const RedisClusterDefaultTimeout = 1
View Source
const RedisClusterHashSlots = 16384
View Source
const RedisClusterRequestTTL = 16

Variables

View Source
var RedisTable = Table{}/* 256 elements not displayed */

Functions

func ChecksumCRC16

func ChecksumCRC16(data []byte) uint16

func Do

func Do(commandName string, args ...interface{}) (reply interface{}, err error)

func SetRefreshNeeded

func SetRefreshNeeded()

Types

type Command

type Command struct {
	CommandName string
	Args        []interface{}
}

func NewCommand

func NewCommand(commandName string, args ...interface{}) (command Command)

func (Command) Append

func (this Command) Append(args interface{}) Command

type Commands

type Commands []Command

func (Commands) Append

func (this Commands) Append(command Command) Commands

type Pool

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

func NewPool

func NewPool(callback func() (redis.Conn, error), maxIdle, maxActive int32) *Pool

func (*Pool) Close

func (this *Pool) Close()

func (*Pool) Do

func (this *Pool) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*Pool) Get

func (this *Pool) Get() (*RedisConn, error)

func (*Pool) Put

func (this *Pool) Put(elem *RedisConn)

func (*Pool) SetLifeTime

func (this *Pool) SetLifeTime(d int)

func (*Pool) SetWaitTime

func (this *Pool) SetWaitTime(d int)

func (*Pool) Update

func (this *Pool) Update(maxIdle, maxActive int32)

type RedisCluster

type RedisCluster struct {
	SeedHosts        map[string]bool
	Handles          map[string]*RedisHandle
	Slots            map[uint16]string
	RefreshTableASAP bool
	SingleRedisMode  bool
	MaxIdle          int
	MaxActive        int
	Debug            bool
}
var Instance RedisCluster

func NewRedisCluster

func NewRedisCluster(addrs []string, max_idle, max_active int, debug bool) RedisCluster

func (*RedisCluster) Do

func (self *RedisCluster) Do(cmd string, args ...interface{}) (reply interface{}, err error)

func (*RedisCluster) GetHandle

func (self *RedisCluster) GetHandle(key string) *RedisHandle

func (*RedisCluster) HandleForKey

func (self *RedisCluster) HandleForKey(key string) *RedisHandle

func (*RedisCluster) KeyForRequest

func (self *RedisCluster) KeyForRequest(cmd string, args ...interface{}) string

func (*RedisCluster) RandomRedisHandle

func (self *RedisCluster) RandomRedisHandle() *RedisHandle

func (*RedisCluster) RedisHandleForSlot

func (self *RedisCluster) RedisHandleForSlot(slot uint16) *RedisHandle

Given a slot return the link (Redis instance) to the mapped node. Make sure to create a connection with the node if we don't have one.

func (*RedisCluster) SendClusterCommand

func (self *RedisCluster) SendClusterCommand(cmd string, args ...interface{}) (reply interface{}, err error)

func (*RedisCluster) SetLifeTime

func (self *RedisCluster) SetLifeTime(t int)

func (*RedisCluster) SetRefreshNeeded

func (self *RedisCluster) SetRefreshNeeded()

func (*RedisCluster) SetWaitTime

func (self *RedisCluster) SetWaitTime(t int)

func (*RedisCluster) SlotForKey

func (self *RedisCluster) SlotForKey(key string) uint16

Return the hash slot from the key.

func (*RedisCluster) TestCluster

func (self *RedisCluster) TestCluster() error

func (*RedisCluster) Update

func (self *RedisCluster) Update(max_idle, max_active int32)

type RedisClusterAccess

type RedisClusterAccess interface {
	Do(commandName string, args ...interface{}) (reply interface{}, err error)
	//	Send(cmd string, args ...interface{}) (err error)
	SetRefreshNeeded()
	HandleForKey(key string) *RedisHandle
}

type RedisConn

type RedisConn struct {
	redis.Conn
	// contains filtered or unexported fields
}

func (*RedisConn) Close

func (this *RedisConn) Close() error

func (RedisConn) Command

func (this RedisConn) Command(commandName string, args ...interface{}) *RedisReply

type RedisHandle

type RedisHandle struct {
	Addr string
	Pool *Pool
}

func HandleForKey

func HandleForKey(key string) *RedisHandle

func NewRedisHandle

func NewRedisHandle(addr string, max_idle, max_active int, debug bool) *RedisHandle

XXX: add some password protection

func (*RedisHandle) Do

func (self *RedisHandle) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*RedisHandle) GetRedisConn

func (self *RedisHandle) GetRedisConn() (*RedisConn, error)

func (*RedisHandle) Send

func (self *RedisHandle) Send(cmd string, args ...interface{}) (err error)

XXX: is _not_ calling defer rc.Close()

so do it yourself later

type RedisReply

type RedisReply struct {
	Type     int           /* REDIS_REPLY_* */
	Integer  int64         /* The integer when type is REDIS_REPLY_INTEGER */
	Len      int           /* Length of string */
	Str      string        /* Used for both REDIS_REPLY_ERROR and REDIS_REPLY_STRING */
	Elements int           /* number of elements, for REDIS_REPLY_ARRAY */
	Element  []*RedisReply /* elements vector for REDIS_REPLY_ARRAY */
}

func NewRedisReply

func NewRedisReply(re interface{}, err error) *RedisReply

type Table

type Table [256]uint16

Table is a 256-word table representing the polynomial for efficient processing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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