From 4564a6edb63733b3991ed1adf9ca94aea773c2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Mon, 25 Nov 2024 20:00:09 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E6=AD=A3Redis=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=8E=8B=E7=BC=A9=E6=AC=A1=E6=95=B0=E8=BF=87=E5=A4=A7?= =?UTF-8?q?=E6=97=B6=EF=BC=8Ckeys=E6=95=B0=E7=BB=84=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E8=B6=8A=E7=95=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.Core/Caching/Cache.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/NewLife.Core/Caching/Cache.cs b/NewLife.Core/Caching/Cache.cs index fd4dac1f3..b7d4a5914 100644 --- a/NewLife.Core/Caching/Cache.cs +++ b/NewLife.Core/Caching/Cache.cs @@ -477,7 +477,7 @@ protected virtual Int64 BenchGet(String[] keys, Int64 times, Int32 threads, Bool { for (var i = k; i < times; i += threads) { - var val = Get(keys[i]); + var val = Get(keys[i % keys.Length]); } } else @@ -486,7 +486,7 @@ protected virtual Int64 BenchGet(String[] keys, Int64 times, Int32 threads, Bool var keys2 = new String[batch]; for (var i = k; i < times; i += threads) { - keys2[n++] = keys[i]; + keys2[n++] = keys[i % keys.Length]; if (n >= batch) { @@ -543,7 +543,7 @@ protected virtual Int64 BenchSet(String[] keys, Int64 times, Int32 threads, Bool { for (var i = k; i < times; i += threads) { - Set(keys[i], val); + Set(keys[i % keys.Length], val); } } else @@ -552,7 +552,7 @@ protected virtual Int64 BenchSet(String[] keys, Int64 times, Int32 threads, Bool var dic = new Dictionary(); for (var i = k; i < times; i += threads) { - dic[keys[i]] = val; + dic[keys[i % keys.Length]] = val; n++; if (n >= batch) @@ -618,7 +618,7 @@ protected virtual Int64 BenchRemove(String[] keys, Int64 times, Int32 threads, B { for (var i = k; i < times; i += threads) { - Remove(keys[i]); + Remove(keys[i % keys.Length]); } } else @@ -627,7 +627,7 @@ protected virtual Int64 BenchRemove(String[] keys, Int64 times, Int32 threads, B var keys2 = new String[batch]; for (var i = k; i < times; i += threads) { - keys2[n++] = keys[i]; + keys2[n++] = keys[i % keys.Length]; if (n >= batch) { @@ -689,7 +689,7 @@ protected virtual Int64 BenchInc(String[] keys, Int64 times, Int32 threads, Bool var val = Rand.Next(100); for (var i = k; i < times; i += threads) { - Increment(keys[i], val); + Increment(keys[i % keys.Length], val); } // 提交变更