mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 17:41:57 +08:00
feat(redis): support confiuring username (#1752)
替换Golang Redis依赖: redigo的版本至当前最新版1.8.9 (v2.0.0被标记为已撤回,且长期未更新) Redis 6 及以上版本均可配置为使用username+password认证的ACL,故作此变更。
This commit is contained in:
1
pkg/cache/driver.go
vendored
1
pkg/cache/driver.go
vendored
@@ -21,6 +21,7 @@ func Init() {
|
||||
10,
|
||||
conf.RedisConfig.Network,
|
||||
conf.RedisConfig.Server,
|
||||
conf.RedisConfig.User,
|
||||
conf.RedisConfig.Password,
|
||||
conf.RedisConfig.DB,
|
||||
)
|
||||
|
||||
3
pkg/cache/redis.go
vendored
3
pkg/cache/redis.go
vendored
@@ -44,7 +44,7 @@ func deserializer(value []byte) (interface{}, error) {
|
||||
}
|
||||
|
||||
// NewRedisStore 创建新的redis存储
|
||||
func NewRedisStore(size int, network, address, password, database string) *RedisStore {
|
||||
func NewRedisStore(size int, network, address, user, password, database string) *RedisStore {
|
||||
return &RedisStore{
|
||||
pool: &redis.Pool{
|
||||
MaxIdle: size,
|
||||
@@ -63,6 +63,7 @@ func NewRedisStore(size int, network, address, password, database string) *Redis
|
||||
network,
|
||||
address,
|
||||
redis.DialDatabase(db),
|
||||
redis.DialUsername(user),
|
||||
redis.DialPassword(password),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
2
pkg/cache/redis_test.go
vendored
2
pkg/cache/redis_test.go
vendored
@@ -13,7 +13,7 @@ import (
|
||||
func TestNewRedisStore(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
|
||||
store := NewRedisStore(10, "tcp", "", "", "0")
|
||||
store := NewRedisStore(10, "tcp", "", "", "", "0")
|
||||
asserts.NotNil(store)
|
||||
|
||||
asserts.Panics(func() {
|
||||
|
||||
@@ -53,6 +53,7 @@ type slave struct {
|
||||
type redis struct {
|
||||
Network string
|
||||
Server string
|
||||
User string
|
||||
Password string
|
||||
DB string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user