Merge pull request #2027 from lintanghui/master

fix:invalid type assert in stringArg
This commit is contained in:
Vladimir Mihailenco 2022-02-18 09:42:50 +02:00 committed by GitHub
commit ed1b5bb28a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

@ -341,6 +341,32 @@ func BenchmarkClusterPing(b *testing.B) {
}) })
} }
func BenchmarkClusterDoInt(b *testing.B) {
if testing.Short() {
b.Skip("skipping in short mode")
}
ctx := context.Background()
cluster := newClusterScenario()
if err := startCluster(ctx, cluster); err != nil {
b.Fatal(err)
}
defer cluster.Close()
client := cluster.newClusterClient(ctx, redisClusterOptions())
defer client.Close()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
err := client.Do(ctx, "SET", 10, 10).Err()
if err != nil {
b.Fatal(err)
}
}
})
}
func BenchmarkClusterSetString(b *testing.B) { func BenchmarkClusterSetString(b *testing.B) {
if testing.Short() { if testing.Short() {
b.Skip("skipping in short mode") b.Skip("skipping in short mode")

View File

@ -151,8 +151,13 @@ func (cmd *baseCmd) stringArg(pos int) string {
if pos < 0 || pos >= len(cmd.args) { if pos < 0 || pos >= len(cmd.args) {
return "" return ""
} }
s, _ := cmd.args[pos].(string) arg := cmd.args[pos]
return s switch v := arg.(type) {
case string:
return v
default:
return fmt.Sprintf("%v", v)
}
} }
func (cmd *baseCmd) firstKeyPos() int8 { func (cmd *baseCmd) firstKeyPos() int8 {