sno-quiz/backend/internal/redis/redis.go
2025-09-17 22:22:14 +03:00

26 lines
434 B
Go

package redis
import (
"context"
"log"
"github.com/redis/go-redis/v9"
)
func Connect(redisURL string) (*redis.Client, error) {
opts, err := redis.ParseURL(redisURL)
if err != nil {
return nil, err
}
rdb := redis.NewClient(opts)
// Ping the server to check the connection
if err := rdb.Ping(context.Background()).Err(); err != nil {
return nil, err
}
log.Println("Redis connected successfully")
return rdb, nil
}