redis

package
v0.1.147 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModCluster     = "cluster"
	ModMasterSlave = "masterSlave"

	PgoMasterSlaveCheckPrefix = "pgo_master_slave_check_"

	NodeActionAdd = "add"
	NodeActionDel = "del"
)

Variables

This section is empty.

Functions

func New

func New(config map[string]interface{}) (interface{}, error)

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

redis:
    prefix: "pgo2_"
    password: ""
    db: 0
    maxIdleConn: 10
    maxIdleTime: "60s"
    netTimeout: "1s"
    probInterval: "0s"
    mod:"cluster"
    servers:
        - "127.0.0.1:6379"
        - "127.0.0.1:6380"

Types

type Client

type Client struct {
	Pool
}

func (*Client) Add

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

func (*Client) Del

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

func (*Client) Do

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

args = [0:"key"]

func (*Client) Exists

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

func (*Client) Expire added in v0.1.137

func (c *Client) Expire(key string, expire time.Duration) (bool, error)

func (*Client) ExpireAt added in v0.1.137

func (c *Client) ExpireAt(key string, timestamp int64) (bool, error)

func (*Client) Get

func (c *Client) Get(key string) (*value.Value, error)

func (*Client) HDel added in v0.1.137

func (c *Client) HDel(key string, fields ...interface{}) (int64, error)

func (*Client) HExists added in v0.1.137

func (c *Client) HExists(key string, field string) (bool, error)

func (*Client) HGet added in v0.1.137

func (c *Client) HGet(key, field string) (*value.Value, error)

func (*Client) HGetAll added in v0.1.137

func (c *Client) HGetAll(key string) (map[string]*value.Value, error)

func (*Client) HIncrBy added in v0.1.137

func (c *Client) HIncrBy(key, field string, delta int64) (int64, error)

func (*Client) HMGet added in v0.1.137

func (c *Client) HMGet(key string, fields ...interface{}) (map[string]*value.Value, error)

func (*Client) HMSet added in v0.1.137

func (c *Client) HMSet(key string, fv ...interface{}) (bool, error)

func (*Client) HSet added in v0.1.137

func (c *Client) HSet(key string, fv ...interface{}) (bool, error)

func (*Client) Incr

func (c *Client) Incr(key string, delta int64) (int64, error)

func (*Client) LLen added in v0.1.137

func (c *Client) LLen(key string) (int64, error)

func (*Client) LPop added in v0.1.137

func (c *Client) LPop(key string) (*value.Value, error)

func (*Client) LPush added in v0.1.137

func (c *Client) LPush(key string, values ...interface{}) (bool, error)

func (*Client) MAdd

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

func (*Client) MDel

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

func (*Client) MGet

func (c *Client) MGet(keys []string) (map[string]*value.Value, error)

func (*Client) MSet

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

func (*Client) RPop added in v0.1.137

func (c *Client) RPop(key string) (*value.Value, error)

func (*Client) RPush added in v0.1.137

func (c *Client) RPush(key string, values ...interface{}) (bool, error)

func (*Client) Set

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

func (*Client) ZAdd added in v0.1.137

func (c *Client) ZAdd(key string, members ...*Z) (int64, error)

func (*Client) ZAddOpt added in v0.1.137

func (c *Client) ZAddOpt(key string, opts []string, members ...*Z) (int64, error)

func (*Client) ZCard added in v0.1.137

func (c *Client) ZCard(key string) (int64, error)

func (*Client) ZRange added in v0.1.137

func (c *Client) ZRange(key string, start, end int) ([]*value.Value, error)

func (*Client) ZRangeWithScores added in v0.1.137

func (c *Client) ZRangeWithScores(key string, start, end int) ([]*ZV, error)

func (*Client) ZRem added in v0.1.137

func (c *Client) ZRem(key string, members ...interface{}) (int64, error)

func (*Client) ZRevRange added in v0.1.137

func (c *Client) ZRevRange(key string, start, end int) ([]*value.Value, error)

func (*Client) ZRevRangeWithScores added in v0.1.137

func (c *Client) ZRevRangeWithScores(key string, start, end int) ([]*ZV, error)

type ClusterPool

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, error)

func (*Conn) Close

func (c *Conn) Close(force bool)

func (*Conn) Do

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

func (*Conn) ExtendDeadLine

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

func (*Conn) ReadReply

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

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

func (*Conn) WriteCmd

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

type IPool

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

type MasterSlavePool

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, error)

func (*Pool) BuildKey

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

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, error)

func (*Pool) GetConnByKey

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

func (*Pool) GetServers

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

func (*Pool) Init

func (p *Pool) Init() error

func (*Pool) RunAddrFunc

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

func (*Pool) SetDb

func (p *Pool) SetDb(db int)

func (*Pool) SetLogger added in v0.1.7

func (p *Pool) SetLogger(logger logs.ILogger)

func (*Pool) SetMaxIdleConn

func (p *Pool) SetMaxIdleConn(v int)

func (*Pool) SetMaxIdleTime

func (p *Pool) SetMaxIdleTime(v string) error

func (*Pool) SetMod

func (p *Pool) SetMod(v string) error

func (*Pool) SetNetTimeout

func (p *Pool) SetNetTimeout(v string) error

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) error

func (*Pool) SetServers

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

type Z added in v0.1.137

type Z struct {
	Score  float64
	Member interface{}
}

Z represents sorted set member.

type ZV added in v0.1.137

type ZV struct {
	Score  *value.Value
	Member *value.Value
}

Jump to

Keyboard shortcuts

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