29 lines
438 B
Go
29 lines
438 B
Go
|
package providers
|
||
|
|
||
|
import "C"
|
||
|
import (
|
||
|
"framework_v2/internal/access"
|
||
|
"github.com/redis/go-redis/v9"
|
||
|
"golang.org/x/net/context"
|
||
|
)
|
||
|
|
||
|
var Redis *redis.Client
|
||
|
|
||
|
func InitRedis() {
|
||
|
Redis = redis.NewClient(&redis.Options{
|
||
|
Addr: Config.Redis.Addr,
|
||
|
Password: Config.Redis.Pass,
|
||
|
DB: 0, // use default DB
|
||
|
})
|
||
|
|
||
|
ctx := context.Background()
|
||
|
|
||
|
err := Redis.Ping(ctx).Err()
|
||
|
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
access.Redis = Redis
|
||
|
}
|