redis

package
v0.0.0-...-a6eea34 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pong = "PONG"
	Nil  = goredis.Nil
)
View Source
const (
	MaxDialTimeout  = 1000
	MaxReadTimeout  = 1000
	MaxWriteTimeout = 3000
	MaxPoolSize     = 1024
	MaxPoolTimeout  = 2 // second
	MinIdleConns    = 3
	MaxRetries      = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*goredis.Client
	*Config
}

Client 客户端

func NewClient

func NewClient(config *Config) (client *Client, err error)

NewClient 创建一个客户端

type Config

type Config struct {
	Name         string
	Network      string
	Addr         string
	Password     string
	DB           int
	DialTimeout  time.Duration // 毫秒
	ReadTimeout  time.Duration // 毫秒
	WriteTimeout time.Duration // 毫秒
	PoolSize     int           // 连接池个数
	PoolTimeout  time.Duration // 超时,秒
	MinIdleConns int           // 空闲
	MaxRetries   int           // 重试次数

}

Config 配置

func (*Config) InitWithDefaults

func (c *Config) InitWithDefaults()

InitWithDefaults 初始化redis配置

type Manager

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

Manager 管理

var (
	// DefaultManager 默认管理
	DefaultManager *Manager
)

func NewManager

func NewManager(cfgs map[string]*Config) *Manager

NewManager 创建一个管理

func NewManagerWithLogger

func NewManagerWithLogger(configs map[string]*Config, l logger.Interface) *Manager

NewManagerWithLogger 返回一个manager对象

func (*Manager) Add

func (mgr *Manager) Add(name string, config *Config) (err error)

Add 添加一个

func (*Manager) Clear

func (mgr *Manager) Clear() (err error)

Clear 清空所有客户端

func (*Manager) Delete

func (mgr *Manager) Delete(name string) (err error)

Delete 删除一个

func (*Manager) Load

func (mgr *Manager) Load(name string) (client *Client, err error)

Load 读取一个

func (*Manager) SetLogger

func (mgr *Manager) SetLogger(l logger.Interface)

SetLogger 设置日志

func (*Manager) Store

func (mgr *Manager) Store(cfgs map[string]*Config)

Store 添加多个

Jump to

Keyboard shortcuts

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