mirror of
https://github.com/hexolan/panels.git
synced 2026-03-26 12:40:21 +00:00
29 lines
564 B
Go
29 lines
564 B
Go
package redis
|
|
|
|
import (
|
|
"time"
|
|
"context"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/redis/go-redis/v9"
|
|
|
|
"github.com/hexolan/panels/panel-service/internal"
|
|
)
|
|
|
|
func NewRedisInterface(ctx context.Context, cfg internal.Config) *redis.Client {
|
|
rdb := redis.NewClient(&redis.Options{
|
|
Addr: cfg.RedisHost,
|
|
Password: cfg.RedisPass,
|
|
DB: 0,
|
|
|
|
DialTimeout: time.Millisecond * 250,
|
|
ReadTimeout: time.Millisecond * 500,
|
|
})
|
|
|
|
_, err := rdb.Ping(ctx).Result()
|
|
if err != nil {
|
|
log.Warn().Err(err).Msg("failed Redis ping")
|
|
}
|
|
|
|
return rdb
|
|
} |