只实现了单机版连接
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package redisx
|
||||
|
||||
type redisOption struct {
|
||||
addr string
|
||||
password string
|
||||
db int
|
||||
poolSize int
|
||||
}
|
||||
|
||||
func defaultOptions() redisOption {
|
||||
return redisOption{
|
||||
addr: "localhost:6379",
|
||||
}
|
||||
}
|
||||
|
||||
type Option func(*redisOption)
|
||||
|
||||
// 127.0.0.1:6379
|
||||
func SetAddress(addr string) Option {
|
||||
return func(o *redisOption) {
|
||||
o.addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
func SetPassword(password string) Option {
|
||||
return func(o *redisOption) {
|
||||
o.password = password
|
||||
}
|
||||
}
|
||||
|
||||
func SetDb(db int) Option {
|
||||
return func(o *redisOption) {
|
||||
o.db = db
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user