2021-12-08 15:31:52 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2022-01-13 19:06:30 +00:00
|
|
|
"context"
|
2022-12-23 22:11:40 +00:00
|
|
|
"log"
|
2021-12-08 15:31:52 +00:00
|
|
|
|
2023-09-04 18:59:51 +00:00
|
|
|
"git.hackmi.ch/Phil/goshorly/utils"
|
2022-01-13 19:06:30 +00:00
|
|
|
"github.com/go-redis/redis/v8"
|
2021-12-08 15:31:52 +00:00
|
|
|
)
|
|
|
|
|
2022-01-13 19:06:30 +00:00
|
|
|
var ctx = context.Background()
|
|
|
|
|
2022-01-25 18:14:09 +00:00
|
|
|
func Client_redis() *redis.Client {
|
|
|
|
var Client *redis.Client = redis.NewClient(&redis.Options{
|
|
|
|
Addr: utils.REDIS_URI, // use default Addr
|
|
|
|
Password: "", // no password set
|
|
|
|
DB: 0, // use default DB
|
|
|
|
})
|
|
|
|
return Client
|
|
|
|
}
|
2021-12-08 15:31:52 +00:00
|
|
|
|
|
|
|
func Init_redis() {
|
2022-12-23 22:11:40 +00:00
|
|
|
_, err := Client_redis().Ping(ctx).Result()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err.Error())
|
|
|
|
}
|
2021-12-08 15:31:52 +00:00
|
|
|
}
|