Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
22 lines
409 B
Go
22 lines
409 B
Go
package platform
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
func OpenRedis(ctx context.Context, url string) (*redis.Client, error) {
|
|
opts, err := redis.ParseURL(url)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("redis: %w", err)
|
|
}
|
|
rdb := redis.NewClient(opts)
|
|
if err := rdb.Ping(ctx).Err(); err != nil {
|
|
_ = rdb.Close()
|
|
return nil, fmt.Errorf("redis: %w", err)
|
|
}
|
|
return rdb, nil
|
|
}
|