-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
44 lines (39 loc) · 874 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package redis
import "github.com/gogf/gf/util/gconv"
type Pool struct {
// 连接池最大阻塞等待时间(使用负值表示没有限制)
MaxWait int
// 连接池中的最大连接
MaxIdle int
// 连接池中的最小连接
MinIdle int
}
type Options struct {
// redis 连接模式,standalone、sentinel、cluster
Mode string
// 服务器地址
Host string
// 服务器连接密码
Password string
// 数据库索引(默认为0)
Database int
// 连接超时时间(毫秒)
Timeout int
// 连接池配置
Pool Pool
}
func NewDefaultOptions(ip string, port int64, password string, database int) Options {
pool := Pool{
MaxWait: -1,
MaxIdle: 10,
MinIdle: 0,
}
return Options{
Mode: "standalone",
Host: ip + ":" + gconv.String(port),
Password: password,
Database: database,
Timeout: 500,
Pool: pool,
}
}