package redis import ( "io" "zero/core/syncx" red "github.com/go-redis/redis" ) var clusterManager = syncx.NewResourceManager() func getCluster(server, pass string) (*red.ClusterClient, error) { val, err := clusterManager.GetResource(server, func() (io.Closer, error) { store := red.NewClusterClient(&red.ClusterOptions{ Addrs: []string{server}, Password: pass, MaxRetries: maxRetries, MinIdleConns: idleConns, }) store.WrapProcess(process) return store, nil }) if err != nil { return nil, err } return val.(*red.ClusterClient), nil }