2024-06-15 16:55:25 +00:00
|
|
|
package redis
|
2024-06-13 01:16:48 +00:00
|
|
|
|
|
|
|
import "C"
|
|
|
|
import (
|
2024-06-15 16:55:25 +00:00
|
|
|
"framework_v2/internal/app/config"
|
2024-06-16 06:16:59 +00:00
|
|
|
"framework_v2/internal/app/facade"
|
2024-06-13 01:16:48 +00:00
|
|
|
"github.com/redis/go-redis/v9"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Redis *redis.Client
|
|
|
|
|
|
|
|
func InitRedis() {
|
|
|
|
Redis = redis.NewClient(&redis.Options{
|
2024-06-15 16:55:25 +00:00
|
|
|
Addr: config.Config.Redis.Addr,
|
|
|
|
Password: config.Config.Redis.Pass,
|
2024-06-13 01:16:48 +00:00
|
|
|
DB: 0, // use default DB
|
|
|
|
})
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
err := Redis.Ping(ctx).Err()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2024-06-16 06:16:59 +00:00
|
|
|
facade.Redis = Redis
|
2024-06-13 01:16:48 +00:00
|
|
|
}
|