redigor

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: MIT Imports: 4 Imported by: 0

README

redigor

提供了redis客户端的三种链接策略:单实例、哨兵、集群。

Redigo Client Demo

Thanks to

github.com/FZambia/sentinel

github.com/gomodule/redigo/redis

github.com/mna/redisc

Documentation

Overview

一些简单的扩展封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDialOpts

func DefaultDialOpts() []redis.DialOption

DefaultDialOpts 默认连接配置

Types

type Client

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

func New

func New(mode ModeInterface) *Client

func (*Client) Do

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

func (*Client) Execute

func (c *Client) Execute(fn ExecuteFunc) (res interface{}, err error)

func (*Client) IntGet

func (c *Client) IntGet(key string) (int, error)

func (*Client) IntSet

func (c *Client) IntSet(key string, val int) (interface{}, error)

func (*Client) Mode

func (c *Client) Mode() string

Mode 当前客户端使用模式 alone 单机或者代理入口模式 cluster Redis-Cluster集群模式 sentinel Redis-Sentinel哨兵模式

func (*Client) StringGet

func (c *Client) StringGet(key string) (string, error)

func (*Client) StringSet

func (c *Client) StringSet(key, val string) (interface{}, error)

func (*Client) Subscribe

func (c *Client) Subscribe(fn SubscribeFunc) error

type ExecuteFunc

type ExecuteFunc func(c redis.Conn) (res interface{}, err error)

ExecuteFunc 普通回调函数

type ModeInterface

type ModeInterface interface {
	fmt.Stringer
	GetConn() redis.Conn
	NewConn() (redis.Conn, error)
}

ModeInterface

type PoolOption

type PoolOption func(pool *redis.Pool)

PoolOption 连接池配置函数

func DefaultPoolOpts

func DefaultPoolOpts() []PoolOption

DefaultPoolOpts 默认连接池配置

func IdleTimeout

func IdleTimeout(value time.Duration) PoolOption

IdleTimeout 最大空闲时长, 超过后关闭连接

func MaxActive

func MaxActive(value int) PoolOption

MaxActive 最多允许的连接数, 0 则无限制

func MaxConnLifetime

func MaxConnLifetime(value time.Duration) PoolOption

MaxConnLifetime 连接生命周期, 超过后关闭连接

func MaxIdle

func MaxIdle(value int) PoolOption

MaxIdle 最多允许空闲的连接数

func TestOnBorrow

func TestOnBorrow(value func(c redis.Conn, t time.Time) (err error)) PoolOption

TestOnBorrow 健康检查, 检测连接是否可用

func Wait

func Wait(value bool) PoolOption

Wait 连接池枯竭是是否阻塞等待

type SubscribeFunc

type SubscribeFunc func(c redis.PubSubConn) (err error)

SubscribeFunc 订阅回调函数

Directories

Path Synopsis
fzambia
Ref : github.com/FZambia/sentinel
Ref : github.com/FZambia/sentinel

Jump to

Keyboard shortcuts

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