redis

package
v0.0.0-...-2e2546a Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewRedis

func NewRedis(c *Config) *Client

func (*Client) GetString

func (r *Client) GetString(key string) (string, error)

func (*Client) Set

func (r *Client) Set(key string, value interface{}, expiration time.Duration) error

type Config

type Config struct {
	Network  string // 网络类型, tcp or unix, 默认tcp
	Address  string
	Password string
	Prefix   string
	DB       int // redis数据库index, 默认0

	// 连接池容量及闲置连接数量
	PoolSize     int // 连接池最大socket连接数, 默认为4倍CPU数
	MinIdleCoons int // 在启动阶段创建指定数量的Idle连接, 并长期维持idle状态的连接数不少于指定数量

	// 超时
	DialTimeout  int // 连接建立超时时间, 默认5秒
	ReadTimeout  int // 读超时, 默认3秒, -1表示取消读超时
	WriteTimeout int // 写超时, 默认等于读超时
	PoolTimeout  int // 当所有连接都处在繁忙状态时, 客户端等待可用连接的最大等待时长, 默认为读超时+1秒

	// 闲置连接检查包括IdleTimeout, MaxConnAge
	IdleTimeOut int
}

Jump to

Keyboard shortcuts

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