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 }