goshorly/db/connection.go

25 lines
407 B
Go
Raw Normal View History

package db
import (
2022-01-13 19:06:30 +00:00
"context"
"log"
2022-01-13 19:06:30 +00:00
"github.com/go-redis/redis/v8"
)
2022-01-13 19:06:30 +00:00
var ctx = context.Background()
var Client *redis.Client = redis.NewClient(&redis.Options{
2022-01-13 19:06:30 +00:00
Addr: "redis:6379", // use default Addr
Password: "", // no password set
DB: 0, // use default DB
})
func Init_redis() {
2022-01-13 19:06:30 +00:00
_, err := Client.Ping(ctx).Result()
if err != nil {
log.Fatal(err.Error())
}
}