diff --git a/aspnet-core/Directory.Build.Volo.targets b/aspnet-core/Directory.Build.Volo.targets index 3481397d..c6402aca 100644 --- a/aspnet-core/Directory.Build.Volo.targets +++ b/aspnet-core/Directory.Build.Volo.targets @@ -89,5 +89,6 @@ + \ No newline at end of file diff --git a/aspnet-core/Directory.Build.targets b/aspnet-core/Directory.Build.targets index 59a9319c..ae0079a1 100644 --- a/aspnet-core/Directory.Build.targets +++ b/aspnet-core/Directory.Build.targets @@ -91,5 +91,10 @@ + + + + + \ No newline at end of file diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.Configure.cs b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.Configure.cs index 88144d95..5b3d91df 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.Configure.cs @@ -1,4 +1,7 @@ -namespace Lion.AbpPro; +using Medallion.Threading; +using Medallion.Threading.Redis; + +namespace Lion.AbpPro; public partial class AbpProHttpApiHostModule { @@ -270,4 +273,18 @@ public partial class AbpProHttpApiHostModule { Configure(options => { options.IsEnabled = MultiTenancyConsts.IsEnabled; }); } + + /// + /// 配置redis分布式锁 + /// + private void ConfigurationDistributedLocking(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + var connectionString = configuration.GetValue("Redis:Configuration"); + context.Services.AddSingleton(sp => + { + var connection = ConnectionMultiplexer.Connect(connectionString); + return new RedisDistributedSynchronizationProvider(connection.GetDatabase()); + }); + } } \ No newline at end of file diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs index 505778a7..fcffb305 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs @@ -1,3 +1,5 @@ +using Volo.Abp.DistributedLocking; + namespace Lion.AbpPro { [DependsOn( @@ -12,7 +14,8 @@ namespace Lion.AbpPro typeof(AbpProCapModule), typeof(AbpProCapEntityFrameworkCoreModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpCachingStackExchangeRedisModule) + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpDistributedLockingModule) //typeof(AbpBackgroundJobsHangfireModule) )] public partial class AbpProHttpApiHostModule : AbpModule @@ -28,6 +31,7 @@ namespace Lion.AbpPro { var configuration = context.Services.GetConfiguration(); ConfigureCache(context); + ConfigurationDistributedLocking(context); ConfigureSwaggerServices(context); ConfigureJwtAuthentication(context, configuration); //ConfigureHangfire(context); diff --git a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj index f485e538..3802047e 100644 --- a/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj +++ b/aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj @@ -40,6 +40,8 @@ + +