From 103af4a9996274caae64175784e278c7e0e3dcf2 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 8 Nov 2024 16:54:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20redis=E6=89=B9=E9=87=8F=E8=8E=B7?= =?UTF-8?q?=E5=BE=97=E7=BC=93=E5=AD=98=E6=95=B0=E6=8D=AE=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/redis/redis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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()