From 1b16e8369dd57a55e5a4a156ddcaae9f00093bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Sun, 2 Feb 2025 10:52:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=92=8CObject=E6=95=B0=E7=BB=84=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E5=87=8F=E5=B0=91GC=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.Redis/FullRedis.cs | 46 ++++++++++++++++++++---------------- NewLife.Redis/RedisClient.cs | 9 +++---- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/NewLife.Redis/FullRedis.cs b/NewLife.Redis/FullRedis.cs index c6aa3a7..93c2a28 100644 --- a/NewLife.Redis/FullRedis.cs +++ b/NewLife.Redis/FullRedis.cs @@ -470,7 +470,11 @@ public class FullRedis : Redis { if (keys == null || keys.Length == 0) return 0; - keys = keys.Select(GetKey).ToArray(); + //keys = keys.Select(GetKey).ToArray(); + for (var i = 0; i < keys.Length; i++) + { + keys[i] = GetKey(keys[i]); + } if (keys.Length == 1) return base.Remove(keys[0]); InitCluster(); @@ -481,7 +485,7 @@ public class FullRedis : Redis } else { - return Execute(keys.FirstOrDefault(), (rds, k) => rds.Execute("DEL", keys), true); + return Execute(keys[0], (rds, k) => rds.Execute("DEL", keys), true); } } #endregion @@ -574,25 +578,25 @@ public class FullRedis : Redis /// public override IDictionary GetDictionary(String key) => new RedisHash(this, key); - /// - /// 获取哈希表所有数据 - /// - /// - /// - /// - public IDictionary GetHashAll(String key) - { - var hashMap = new RedisHash(this, key); - var nCount = hashMap!.Count(); - var sModel = new SearchModel() - { - Pattern = "*", - Position = 0, - Count = nCount - }; - return hashMap!.Search(sModel).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - } - + /// + /// 获取哈希表所有数据 + /// + /// + /// + /// + public IDictionary GetHashAll(String key) + { + var hashMap = new RedisHash(this, key); + var nCount = hashMap!.Count(); + var sModel = new SearchModel() + { + Pattern = "*", + Position = 0, + Count = nCount + }; + return hashMap!.Search(sModel).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + } + /// 获取队列,快速LIST结构,无需确认 /// /// 消息队列主题 diff --git a/NewLife.Redis/RedisClient.cs b/NewLife.Redis/RedisClient.cs index ca8a61c..e72596a 100644 --- a/NewLife.Redis/RedisClient.cs +++ b/NewLife.Redis/RedisClient.cs @@ -999,16 +999,17 @@ public class RedisClient : DisposeBase { if (values == null || values.Count == 0) throw new ArgumentNullException(nameof(values)); - var ps = new List(); + var k = 0; + var ps = new Object[values.Count * 2]; foreach (var item in values) { - ps.Add(item.Key); + ps[k++] = item.Key; if (item.Value == null) throw new NullReferenceException(); - ps.Add(item.Value); + ps[k++] = item.Value; } - var rs = Execute("MSET", ps.ToArray()); + var rs = Execute("MSET", ps); if (rs != "OK") { using var span = Host.Tracer?.NewSpan($"redis:{Name}:ErrorSetAll", values);