From c28caa43b8a5007b22a7938469d714f5602d904e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Mon, 28 Oct 2024 11:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E3=80=90=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E3=80=91=EF=BC=9A=E6=9B=B4=E6=96=B0=E6=89=80=E6=9C=89=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E7=BB=84=E4=BB=B6=E5=88=B0=E6=9C=80=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E8=B0=83=E6=95=B4initq=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=98=9F=E5=88=97=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4skit=E5=BE=AE=E4=BF=A1=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E7=BB=84=E4=BB=B6=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/RedisMessageQueueSetup.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CoreCms.Net.Core/Config/RedisMessageQueueSetup.cs b/CoreCms.Net.Core/Config/RedisMessageQueueSetup.cs index 33499b9a..57532c5c 100644 --- a/CoreCms.Net.Core/Config/RedisMessageQueueSetup.cs +++ b/CoreCms.Net.Core/Config/RedisMessageQueueSetup.cs @@ -23,6 +23,21 @@ namespace CoreCms.Net.Core.Config { if (services == null) throw new ArgumentNullException(nameof(services)); + var dbIndex = 0; + var ConnectionString = AppSettingsConstVars.RedisConfigConnectionString; + if (!string.IsNullOrEmpty(ConnectionString)) + { + var arr = ConnectionString.ToLower().Split(','); + if (arr.Length > 1) + { + var defaultDataBaseStr = arr.FirstOrDefault(p => p.Contains("defaultdatabase")); + if (!string.IsNullOrEmpty(defaultDataBaseStr)) + { + dbIndex = defaultDataBaseStr.Split('=').LastOrDefault("0").ObjToInt(0); + } + } + } + services.AddInitQ(m => { //没消息时挂起时长(毫秒) @@ -51,6 +66,8 @@ namespace CoreCms.Net.Core.Config }; //显示日志 m.ShowLog = false; + //新增自定redis驱动器 + m.DbIndex = dbIndex; }); }