mirror of
https://github.com/go-eagle/eagle.git
synced 2025-10-05 16:46:59 +08:00
28 lines
674 B
Go
28 lines
674 B
Go
package redis
|
|
|
|
import (
|
|
"github.com/go-redis/redis"
|
|
"github.com/lexkong/log"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var Client *redis.Client
|
|
|
|
func init() {
|
|
Client = redis.NewClient(&redis.Options{
|
|
Addr: viper.GetString("redis.addr"),
|
|
Password: viper.GetString("redis.password"),
|
|
DB: viper.GetInt("redis.db"),
|
|
DialTimeout: viper.GetDuration("redis.dial_timeout"),
|
|
ReadTimeout: viper.GetDuration("redis.read_timeout"),
|
|
WriteTimeout: viper.GetDuration("redis.write_timeout"),
|
|
PoolSize: viper.GetInt("redis.pool_size"),
|
|
})
|
|
|
|
_, err := Client.Ping().Result()
|
|
if err != nil {
|
|
log.Errorf(err, "[redis] redis ping err: %+v")
|
|
panic(err)
|
|
}
|
|
}
|