Documentation
¶
Overview ¶
Package gredis provides client for redis server.
Redis客户端. Redis中文手册文档请参考:http://redisdoc.com/ , Redis官方命令请参考:https://redis.io/commands
Index ¶
- type Config
- type Conn
- type PoolStats
- type Redis
- func (r *Redis) Close() error
- func (r *Redis) Conn() Conn
- func (r *Redis) Do(command string, args ...interface{}) (interface{}, error)
- func (r *Redis) GetConn() Conn
- func (r *Redis) Send(command string, args ...interface{}) error
- func (r *Redis) SetIdleTimeout(value time.Duration)
- func (r *Redis) SetMaxActive(value int)
- func (r *Redis) SetMaxConnLifetime(value time.Duration)
- func (r *Redis) SetMaxIdle(value int)
- func (r *Redis) Stats() *PoolStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Host string // 地址 Port int // 端口 Db int // 数据库 Pass string // 授权密码 MaxIdle int // 最大允许空闲存在的连接数(默认为0表示不存在闲置连接) MaxActive int // 最大连接数量限制(默认为0表示不限制) IdleTimeout time.Duration // 连接最大空闲时间(默认为60秒,不允许设置为0) MaxConnLifetime time.Duration // 连接最长存活时间(默认为60秒,不允许设置为0) }
Redis服务端但节点连接配置信息
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis客户端(管理连接池)
func New ¶
New creates a redis client object with given configuration. Redis client maintains a connection pool automatically.
创建redis操作对象.
func (*Redis) Close ¶
Close closes the redis connection pool, it will release all connections reserved by this pool.
关闭redis管理对象,将会关闭底层的连接池。
func (*Redis) Do ¶
Do sends a command to the server and returns the received reply. Do automatically get a connection from pool, and close it when reply received.
执行同步命令,自动从连接池中获取连接,使用完毕后关闭连接(丢回连接池),开发者不用自行Close.
func (*Redis) GetConn ¶
GetConn returns a raw connection object, which expose more methods communication with server. **You should call Close function manually if you do not use this connection any further.**
获得一个原生的redis连接对象,用于自定义连接操作, 但是需要注意的是如果不再使用该连接对象时,需要手动Close连接,否则会造成连接数超限。
func (*Redis) Send ¶
Deprecated. Send writes the command to the client's output buffer.
执行异步命令 - Send
func (*Redis) SetIdleTimeout ¶
SetMaxIdle sets the IdleTimeout attribute of the connection pool.
设置属性 - IdleTimeout
func (*Redis) SetMaxActive ¶
SetMaxIdle sets the MaxActive attribute of the connection pool.
设置属性 - MaxActive
func (*Redis) SetMaxConnLifetime ¶
SetMaxIdle sets the MaxConnLifetime attribute of the connection pool.
设置属性 - MaxConnLifetime
func (*Redis) SetMaxIdle ¶
SetMaxIdle sets the MaxIdle attribute of the connection pool.
设置属性 - MaxIdle