Redis

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdapterClass = "@pgo/Client/Redis/Adapter"

	ModCluster     = "cluster"
	ModMasterSlave = "masterSlave"

	PgoMasterSlaveCheckPrefix = "pgo_master_slave_check_"

	NodeActionAdd = "add"
	NodeActionDel = "del"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	pgo.Object
	// contains filtered or unexported fields
}

Adapter of Redis Client, add context support. usage: redis := this.GetObject(Redis.AdapterClass).(*Redis.Adapter)

func (*Adapter) Add

func (a *Adapter) Add(key string, value interface{}, expire ...time.Duration) bool

func (*Adapter) Construct

func (a *Adapter) Construct(componentId ...string)

func (*Adapter) Del

func (a *Adapter) Del(key string) bool

func (*Adapter) Do added in v0.1.2

func (a *Adapter) Do(cmd string, args ...interface{}) interface{}

支持的命令请查阅:Redis.allRedisCmd args = [0:"key"] Example: redis := t.GetObject(Redis.AdapterClass).(*Redis.Adapter) retI := redis.Do("SADD","myTest", "test1") ret := retI.(int) fmt.Println(ret) = 1 retList :=redis.Do("SMEMBERS","myTest") retListI,_:=ret.([]interface{})

for _,v:=range retListI{
   vv :=pgo.NewValue(v) // 写入的时候有pgo.Encode(),如果存入的是结构体或slice map 需要decode,其他类型直接断言类型
   fmt.Println(vv.String()) // test1
}

func (*Adapter) Exists

func (a *Adapter) Exists(key string) bool

func (*Adapter) Get

func (a *Adapter) Get(key string) *pgo.Value

func (*Adapter) GetClient

func (a *Adapter) GetClient() *Client

func (*Adapter) Incr

func (a *Adapter) Incr(key string, delta int) int

func (*Adapter) MAdd

func (a *Adapter) MAdd(items map[string]interface{}, expire ...time.Duration) bool

func (*Adapter) MDel

func (a *Adapter) MDel(keys []string) bool

func (*Adapter) MGet

func (a *Adapter) MGet(keys []string) map[string]*pgo.Value

func (*Adapter) MSet

func (a *Adapter) MSet(items map[string]interface{}, expire ...time.Duration) bool

func (*Adapter) Set

func (a *Adapter) Set(key string, value interface{}, expire ...time.Duration) bool

func (*Adapter) SetPanicRecover

func (a *Adapter) SetPanicRecover(v bool)

type Client

type Client struct {
	Pool
}

Redis Client component, require redis-server 2.6.12+ configuration: redis:

class: "@pgo/Client/Redis/Client"
prefix: "pgo_"
password: ""
db: 0
maxIdleConn: 10
maxIdleTime: "60s"
netTimeout: "1s"
probInterval: "0s"
mod:"cluster"
servers:
    - "127.0.0.1:6379"
    - "127.0.0.1:6380"

func (*Client) Add

func (c *Client) Add(key string, value interface{}, expire ...time.Duration) bool

func (*Client) Del

func (c *Client) Del(key string) bool

func (*Client) Do added in v0.1.2

func (c *Client) Do(cmd string, args ...interface{}) interface{}

args = [0:"key"]

func (*Client) Exists

func (c *Client) Exists(key string) bool

func (*Client) Get

func (c *Client) Get(key string) *pgo.Value

func (*Client) Incr

func (c *Client) Incr(key string, delta int) int

func (*Client) MAdd

func (c *Client) MAdd(items map[string]interface{}, expire ...time.Duration) bool

func (*Client) MDel

func (c *Client) MDel(keys []string) bool

func (*Client) MGet

func (c *Client) MGet(keys []string) map[string]*pgo.Value

func (*Client) MSet

func (c *Client) MSet(items map[string]interface{}, expire ...time.Duration) bool

func (*Client) Set

func (c *Client) Set(key string, value interface{}, expire ...time.Duration) bool

type ClusterPool added in v0.1.3

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

type Conn

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

func (*Conn) CheckActive

func (c *Conn) CheckActive() bool

func (*Conn) Close

func (c *Conn) Close(force bool)

func (*Conn) Do

func (c *Conn) Do(cmd string, args ...interface{}) interface{}

func (*Conn) ExtendDeadLine

func (c *Conn) ExtendDeadLine(deadLine ...time.Duration) bool

func (*Conn) ReadReply

func (c *Conn) ReadReply() interface{}

read reply from server, return []byte, int, nil or slice of these types

func (*Conn) WriteCmd

func (c *Conn) WriteCmd(cmd string, args ...interface{})

type IPool added in v0.1.3

type IPool interface {
	// contains filtered or unexported methods
}

type MasterSlavePool added in v0.1.3

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

type Pool

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

func (*Pool) AddrNewKeys

func (p *Pool) AddrNewKeys(cmd string, v interface{}) (map[string][]string, map[string]string)

func (*Pool) BuildKey

func (p *Pool) BuildKey(key string) string

func (*Pool) Construct

func (p *Pool) Construct()

func (*Pool) GetAddrByKey

func (p *Pool) GetAddrByKey(cmd, key string, prevDft ...string) string

get redis address/node prevDft 一般用于master-slave mset mget mdel

func (*Pool) GetConnByAddr

func (p *Pool) GetConnByAddr(addr string) *Conn

func (*Pool) GetConnByKey

func (p *Pool) GetConnByKey(cmd, key string) *Conn

func (*Pool) GetServers

func (p *Pool) GetServers() (servers []string)

func (*Pool) Init

func (p *Pool) Init()

func (*Pool) RunAddrFunc

func (p *Pool) RunAddrFunc(addr string, keys []string, wg *sync.WaitGroup, f func(*Conn, []string))

func (*Pool) SetDb

func (p *Pool) SetDb(db int)

func (*Pool) SetMaxIdleConn

func (p *Pool) SetMaxIdleConn(v int)

func (*Pool) SetMaxIdleTime

func (p *Pool) SetMaxIdleTime(v string)

func (*Pool) SetMod added in v0.1.2

func (p *Pool) SetMod(v string)

func (*Pool) SetNetTimeout

func (p *Pool) SetNetTimeout(v string)

func (*Pool) SetPassword

func (p *Pool) SetPassword(password string)

func (*Pool) SetPrefix

func (p *Pool) SetPrefix(prefix string)

func (*Pool) SetProbeInterval

func (p *Pool) SetProbeInterval(v string)

func (*Pool) SetServers

func (p *Pool) SetServers(v []interface{})

Jump to

Keyboard shortcuts

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