diff --git a/src/framework/redis/redis.go b/src/framework/redis/redis.go index 8453176e..eb361217 100644 --- a/src/framework/redis/redis.go +++ b/src/framework/redis/redis.go @@ -265,7 +265,6 @@ func GetHashBatch(source string, keys []string) (map[string]map[string]string, e if source != "" { rdb = RDB(source) } - ctx := context.Background() // 创建一个有限的并发控制信号通道 sem := make(chan struct{}, 10) @@ -280,11 +279,13 @@ func GetHashBatch(source string, keys []string) (map[string]map[string]string, e for i := 0; i < total; i += batchSize { wg.Add(1) go func(start int) { + ctx := context.Background() // 并发控制,限制同时执行的 Goroutine 数量 sem <- struct{}{} defer func() { - wg.Done() <-sem + ctx.Done() + wg.Done() }() pipe := rdb.Pipeline()