Skip to content

Commit

Permalink
redis support without password
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpingcoder committed Jul 11, 2021
1 parent 3202e68 commit 0685c70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion utils/cryptoutil/CryptoUtil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func TestMD5Encrypt(t *testing.T) {
}

func TestHmacMD5Encrypt(t *testing.T) {
t.Log(HmacMD5("1234",[]byte("123456")))
t.Log(HmacMD5("test0",[]byte("zxcv1234")))
}
14 changes: 10 additions & 4 deletions utils/redisutil/RedisUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ var redisClients map[string]*redis.Client = make(map[string]*redis.Client)
func InitFromConfig(configs []interface{}, decryptKey string, decryptHandler func(content string, decryptKey string) string) bool {
for _, config := range configs {
configMap := config.(map[string]interface{})
if configMap["RedisName"] == nil || configMap["Addr"] == nil || configMap["Password"] == nil || configMap["DB"] == nil {
logutil.Error("RedisName、Addr、Password、DB为必填项", nil)
if configMap["RedisName"] == nil || configMap["Addr"] == nil {
logutil.Error("RedisName、Addr为必填项", nil)
return false
}
redisName := configMap["RedisName"].(string)
addr := configMap["Addr"].(string)
password := decryptHandler(configMap["Password"].(string), decryptKey)
db := int(configMap["DB"].(float64))
password := ""
if configMap["Password"] != nil {
password = decryptHandler(configMap["Password"].(string), decryptKey)
}
db := 0
if configMap["DB"] != nil {
db = int(configMap["DB"].(float64))
}
maxRetries := -1
poolSize := 200
minIdleConns := 100
Expand Down

0 comments on commit 0685c70

Please sign in to comment.