EasilyNET.MongoDistributedLock.AspNetCore 1.7.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasilyNET.MongoDistributedLock.AspNetCore --version 1.7.5                
NuGet\Install-Package EasilyNET.MongoDistributedLock.AspNetCore -Version 1.7.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasilyNET.MongoDistributedLock.AspNetCore" Version="1.7.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasilyNET.MongoDistributedLock.AspNetCore --version 1.7.5                
#r "nuget: EasilyNET.MongoDistributedLock.AspNetCore, 1.7.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasilyNET.MongoDistributedLock.AspNetCore as a Cake Addin
#addin nuget:?package=EasilyNET.MongoDistributedLock.AspNetCore&version=1.7.5

// Install EasilyNET.MongoDistributedLock.AspNetCore as a Cake Tool
#tool nuget:?package=EasilyNET.MongoDistributedLock.AspNetCore&version=1.7.5                
EasilyNET.MongoDistributedLock.AspNetCore
  • EasilyNET.MongoDistributedLock.AspNetCore 让基于 EasilyNET.MongoDistributedLock 的使用更简单.

  • 注册服务

// 使用默认配置
builder.Services.AddMongoDistributedLock();

// 自定义一些配置
builder.Services.AddMongoDistributedLock(op =>
{
    op.DatabaseName = "test_locks";
    op.MaxDocument = 100;
    ...
});
  • 使用
public class DistributedLockTest(IDistributedLock mongoLock)
{
    public async Task<dynamic> AcquireLock()
    {
        var acq = await mongoLock.AcquireAsync(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(0));
        try
        {
            if (acq.Acquired)
            {
                // 关键部分,它不能一次由任何服务器上的多个线程执行
                // ...
                // ...
            }
            else
            {
                // 超时!也许另一个线程没有释放锁...我们可以再试一次或抛出例外
            }
        }
        finally
        {
            // 如果(acq.Acquired)无需手动操作
            await mongoLock.ReleaseAsync(acq);
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.24.919.92 41 9/19/2024
3.24.914.125 68 9/14/2024
3.24.914.115 71 9/14/2024
3.24.914.111 69 9/14/2024
3.24.911.95 79 9/11/2024
3.24.908.215 52 9/8/2024
3.24.904.200 59 9/4/2024
3.24.828.163 81 8/28/2024
3.24.820.173 74 8/20/2024
3.24.814.92 88 8/14/2024
3.24.812.115 79 8/12/2024
3.24.802.100 47 8/2/2024
3.24.801.162 58 8/1/2024
3.24.801.160 55 8/1/2024
3.24.801.155 55 8/1/2024
3.24.730.164 48 7/30/2024
3.24.730.91 46 7/30/2024
3.24.724.91 50 7/24/2024
3.24.718.105 75 7/18/2024
3.24.716.95 76 7/16/2024
3.24.712.94 67 7/12/2024
3.24.710.14 83 7/9/2024
3.24.709.105 84 7/9/2024
3.24.704.94 88 7/4/2024
3.24.701.90 88 7/1/2024
3.24.628.114 92 6/28/2024
3.24.627.145 79 6/27/2024
3.24.620.160 77 6/20/2024
3.24.613.115 82 6/13/2024
3.24.612.95 76 6/12/2024
3.24.528.90 81 5/28/2024
3.24.522.84 91 5/22/2024
3.24.512.213 73 5/12/2024
3.24.508.112 96 5/8/2024
2.2024.428.71 82 4/28/2024
2.2024.427.1128 94 4/27/2024
2.2.72 99 4/14/2024
2.2.71 90 4/12/2024
2.2.8 83 4/26/2024
2.2.6 83 4/10/2024
2.2.5 103 3/26/2024
2.2.4 100 3/25/2024
2.2.3 102 3/24/2024
2.2.2 105 3/21/2024
2.2.1 106 3/20/2024
2.2.0 107 3/13/2024
2.1.9 99 2/21/2024
2.1.8 106 2/18/2024
2.1.7 92 2/16/2024
2.1.6 96 2/14/2024
2.1.5 102 2/14/2024
2.1.4 108 2/9/2024
2.1.3 137 2/8/2024
2.1.2 91 2/5/2024
2.1.1.2 165 12/26/2023
2.1.1.1 102 12/26/2023
2.1.1 118 12/25/2023
2.1.0 119 12/17/2023
2.0.11 143 12/6/2023
2.0.1 138 11/15/2023
2.0.0 114 11/14/2023
1.9.1 121 11/1/2023
1.9.0 116 10/19/2023
1.9.0-preview2 95 10/12/2023
1.9.0-preview1 95 10/12/2023
1.8.9 126 10/11/2023
1.8.8 123 10/11/2023
1.8.7-rc2 96 9/21/2023
1.8.7-rc1 100 9/12/2023
1.8.6 147 8/31/2023
1.8.5 126 8/25/2023
1.8.4 138 8/24/2023
1.8.3 142 8/23/2023
1.8.2 138 8/22/2023
1.8.1 149 8/18/2023
1.8.0 151 8/15/2023
1.7.9 167 8/11/2023
1.7.8 150 8/11/2023
1.7.7 154 8/10/2023
1.7.6 169 8/9/2023
1.7.5 140 8/9/2023
1.7.4 155 8/3/2023
1.7.3 158 8/1/2023
1.7.2 148 7/31/2023
1.7.1 142 7/27/2023
1.7.0 154 7/27/2023