Эх сурвалжийг харах

redis kit:CreateScopeAsync

dodo hold 1 жил өмнө
parent
commit
4af9a923bf

+ 1 - 1
molilian.api/Program.cs

@@ -7,7 +7,7 @@ using Microsoft.Extensions.Diagnostics.HealthChecks;
 using Microsoft.AspNetCore.Diagnostics.HealthChecks;
 
 var builder = WebApplication.CreateBuilder(args);
-builder.Services.Init();
+await builder.Services.InitAsync();
 
 builder.Services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
 builder.Services.AddControllers(option =>

+ 1 - 1
molilian.api/molilian.api.csproj

@@ -15,7 +15,7 @@
     <PackageReference Include="dodohold.core" Version="1.0.1.17" />
     <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.0-Preview.1" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
-    <PackageReference Include="YunhuiKit" Version="0.0.12" />
+    <PackageReference Include="YunhuiKit" Version="0.0.14" />
   </ItemGroup>
 
   <ItemGroup>

+ 3 - 3
molilian.core/Core/log/base.cs

@@ -35,7 +35,7 @@ namespace molilian.core
                         if (string.IsNullOrEmpty(redisServer)) return 0;
                         try
                         {
-                            await using var scope = RedisClientFactory.CreateScope(redisServer);
+                            await using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                             return BatchInsertLogDB(limit, scope.Client);
                         }
                         catch (Exception ex)
@@ -527,7 +527,7 @@ namespace molilian.core
 
                         try
                         {
-                            await using var scope = RedisClientFactory.CreateScope(redisServer);
+                            await using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                             return await scope.Client.GetAsync<int>(keyname);
                         }
                         catch (Exception)
@@ -558,7 +558,7 @@ namespace molilian.core
                     var redisServer = EndPointCore.GetRedisServer(node);
                     if (string.IsNullOrEmpty(redisServer)) return [];
 
-                    using var scope = RedisClientFactory.CreateScope(redisServer);
+                    using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                     return await scope.Client.SMembersAsync<string>(keyname);
                 }
                 catch (Exception ex)

+ 3 - 2
molilian.core/Core/taoke/OrderTrackingCore.cs

@@ -74,7 +74,8 @@ namespace molilian.core
                         var redisServer = EndPointCore.GetRedisServer(node);
                         if (string.IsNullOrEmpty(redisServer)) return null;
 
-                        using var scope = RedisClientFactory.CreateScope(redisServer);
+
+                        using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                         var redis = scope.Client;
 
                         // 按优先级依次查询不同的缓存key
@@ -122,7 +123,7 @@ namespace molilian.core
                         var redisServer = EndPointCore.GetRedisServer(node);
                         if (string.IsNullOrEmpty(redisServer)) return;
 
-                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                         var redis = scope.Client;
 
                         var keys = new[]

+ 2 - 2
molilian.core/Core/taoke/RiskControlCore.cs

@@ -131,7 +131,7 @@ namespace molilian.core
                         if (string.IsNullOrEmpty(redisServer)) return 0;
 
                         var cacheKey = $"RiskControl:{key}:calls:{flag}";
-                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                         return await scope.Client.GetAsync<int>(cacheKey);
                     });
 
@@ -182,7 +182,7 @@ namespace molilian.core
                         var redisServer = EndPointCore.GetRedisServer(node);
                         if (string.IsNullOrEmpty(redisServer)) return false;
 
-                        using var scope = RedisClientFactory.CreateScope(redisServer);
+                        using var scope = await RedisClientFactory.CreateScopeAsync(redisServer);
                         return await scope.Client.SetAsync(cache_key, income_amt, 3 * 86400);
                     });
 

+ 2 - 2
molilian.core/middleware/CustomToken.cs

@@ -9,7 +9,7 @@ namespace molilian.core
 {
     public static class CustomToken
     {
-        public static IServiceCollection Init(this IServiceCollection services)
+        public static async Task<IServiceCollection> InitAsync(this IServiceCollection services)
         {
             //int minWorkerThreads = 128;  // 工作线程数的建议设置
             //int minIOCompletionThreads = 512;  // I/O 完成端口线程数的建议设置
@@ -43,7 +43,7 @@ namespace molilian.core
             SystemMonitor.StartMonitoring(30);
 
             var connstr = Environment.GetEnvironmentVariable("RedisConfig") ?? throw new ArgumentNullException("找不到对应的RedisConfig配置!");
-            RedisKit.Initialize(connstr);
+            await RedisKit.InitializeAsync(connstr);
 
 
 

+ 1 - 1
molilian.core/molilian.core.csproj

@@ -25,7 +25,7 @@
     <PackageReference Include="IP2Region.Net" Version="2.0.2" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
     <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
-    <PackageReference Include="YunhuiKit" Version="0.0.12" />
+    <PackageReference Include="YunhuiKit" Version="0.0.14" />
   </ItemGroup>
 
   <ItemGroup>