只实现了单机版连接

This commit is contained in:
Yun
2024-03-13 15:07:00 +08:00
commit c661caf3a7
5 changed files with 117 additions and 0 deletions
+35
View File
@@ -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
}
}