redis

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 10 Imported by: 1

README

思路

一. 执行命令

  1. 检查是否连接,如果没有连接则进行连接。
  2. 连接建立后,先将管道中的命令发送到该连接,然后执行当前命令。
  3. 如果当前命令执行失败,如果是超时导致,则重连。重连后,重复步骤 2。
  4. 返回执行结果。

二. 执行管道中的命令

  1. 检查是否连接,如果没有连接则进行连接。
  2. 先将管道中的命令发送到该连接。
  3. 刷新连接。
  4. 在该连接上获取接收结果。如果获取超时,则重连。重连后,重复步骤 2、3。
  5. 返回执行结果。

三. 事务

  1. 开始事务。
  2. 向管道发送命令。
  3. 进行步骤一。

四. 重连

  • 将当前连接释放掉,然后重新连接。

参考

Documentation

Index

Constants

View Source
const (
	DefaultConnectTimeout = 10 * time.Second
	DefaultReadTimeout    = 10 * time.Second
	DefaultWriteTimeout   = 10 * time.Second
)
View Source
const (
	FiledTag = "redis"
)

Variables

This section is empty.

Functions

func ReflectSaveEntityArgs

func ReflectSaveEntityArgs(rev reflect.Value) []interface{}

Types

type Client

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

func NewClient

func NewClient(config *Config, logger golog.ILogger) *Client

func (*Client) BeginTrans

func (c *Client) BeginTrans()

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) DiscardTrans

func (c *Client) DiscardTrans() error

func (*Client) Do

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

func (*Client) DoWithoutLog

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

func (*Client) ExecTrans

func (c *Client) ExecTrans() ([]*Reply, error)

func (*Client) FlushCmdQueue

func (c *Client) FlushCmdQueue() ([]*Reply, []int)

func (*Client) Free

func (c *Client) Free()

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) Send

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

func (*Client) SetLogger

func (c *Client) SetLogger(logger golog.ILogger) *Client

func (*Client) SetTraceId

func (c *Client) SetTraceId(traceId []byte) *Client

type Cmd

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

func NewCmd

func NewCmd(cmd string, args []interface{}) *Cmd

type Config

type Config struct {
	LogLevel int

	Host string
	Port string
	Pass string

	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration

	IsTimeoutAutoConnect bool
}

func NewConfig

func NewConfig(host, port, pass string) *Config

type NewClientFunc

type NewClientFunc func() (*Client, error)

type Pool

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

func NewPool

func NewPool(config *PoolConfig) *Pool

func (*Pool) Get

func (p *Pool) Get() (*Client, error)

func (*Pool) Put

func (p *Pool) Put(client *Client) error

type PoolConfig added in v1.2.0

type PoolConfig struct {
	pool.Config

	NewClientFunc func() (*Client, error)

	LogKeepAlive bool
}

type Reply

type Reply struct {
	Err error
	// contains filtered or unexported fields
}

func NewReply

func NewReply(reply interface{}, err error) *Reply

func (*Reply) ArrReplyIsNil

func (r *Reply) ArrReplyIsNil() bool

func (*Reply) Bool

func (r *Reply) Bool() (bool, error)

func (*Reply) ByteSlices

func (r *Reply) ByteSlices() ([][]byte, error)

func (*Reply) Bytes

func (r *Reply) Bytes() ([]byte, error)

func (*Reply) Float64

func (r *Reply) Float64() (float64, error)

func (*Reply) Int

func (r *Reply) Int() (int, error)

func (*Reply) Int64

func (r *Reply) Int64() (int64, error)

func (*Reply) Int64Map

func (r *Reply) Int64Map() (map[string]int64, error)

func (*Reply) Int64s

func (r *Reply) Int64s() ([]int64, error)

func (*Reply) Ints

func (r *Reply) Ints() ([]int, error)

func (*Reply) SimpleReplyIsNil

func (r *Reply) SimpleReplyIsNil() bool

func (*Reply) String

func (r *Reply) String() (string, error)

func (*Reply) StringMap

func (r *Reply) StringMap() (map[string]string, error)

func (*Reply) Strings

func (r *Reply) Strings() ([]string, error)

func (*Reply) Struct

func (r *Reply) Struct(s interface{}) error

func (*Reply) Uint64

func (r *Reply) Uint64() (uint64, error)

type SimpleOrm

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

func NewSimpleOrm

func NewSimpleOrm(traceId []byte, pool *Pool) *SimpleOrm

func (*SimpleOrm) Client

func (so *SimpleOrm) Client() *Client

func (*SimpleOrm) Del

func (so *SimpleOrm) Del(key string) error

func (*SimpleOrm) GetAsJson

func (so *SimpleOrm) GetAsJson(key string, value interface{}) (bool, error)

func (*SimpleOrm) GetEntity

func (so *SimpleOrm) GetEntity(key string, entityPtr interface{}) (bool, error)

func (*SimpleOrm) PutBackClient

func (so *SimpleOrm) PutBackClient()

func (*SimpleOrm) Renew

func (so *SimpleOrm) Renew(traceId []byte, pool *Pool) *SimpleOrm

func (*SimpleOrm) SaveAsJson

func (so *SimpleOrm) SaveAsJson(key string, value interface{}, expireSeconds int64) error

func (*SimpleOrm) SaveEntity

func (so *SimpleOrm) SaveEntity(key string, entity interface{}, expireSeconds int64) error

Jump to

Keyboard shortcuts

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