update: The code structure is finished, and the project can run successfully
This commit is contained in:
22
server/initialize/redis.go
Normal file
22
server/initialize/redis.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"gin-vue-admin/global"
|
||||
"github.com/go-redis/redis"
|
||||
)
|
||||
|
||||
func Redis() {
|
||||
redisCfg := global.GVA_CONFIG.Redis
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: redisCfg.Addr,
|
||||
Password: redisCfg.Password, // no password set
|
||||
DB: redisCfg.DB, // use default DB
|
||||
})
|
||||
pong, err := client.Ping().Result()
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error(err)
|
||||
} else {
|
||||
global.GVA_LOG.Info("redis connect ping response:", pong)
|
||||
global.GVA_REDIS = client
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user