EasilyNET.MongoDistributedLock.AspNetCore 1.7.6

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.6                
NuGet\Install-Package EasilyNET.MongoDistributedLock.AspNetCore -Version 1.7.6                
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.6" />                
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.6                
#r "nuget: EasilyNET.MongoDistributedLock.AspNetCore, 1.7.6"                
#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.6

// Install EasilyNET.MongoDistributedLock.AspNetCore as a Cake Tool
#tool nuget:?package=EasilyNET.MongoDistributedLock.AspNetCore&version=1.7.6                
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.716.95 29 7/16/2024
3.24.712.94 29 7/12/2024
3.24.710.14 64 7/9/2024
3.24.709.105 71 7/9/2024
3.24.704.94 77 7/4/2024
3.24.701.90 80 7/1/2024
3.24.628.114 86 6/28/2024
3.24.627.145 72 6/27/2024
3.24.620.160 70 6/20/2024
3.24.613.115 78 6/13/2024
3.24.612.95 71 6/12/2024
3.24.528.90 75 5/28/2024
3.24.522.84 87 5/22/2024
3.24.512.213 69 5/12/2024
3.24.508.112 93 5/8/2024
2.2024.428.71 80 4/28/2024
2.2024.427.1128 91 4/27/2024
2.2.72 97 4/14/2024
2.2.71 85 4/12/2024
2.2.8 81 4/26/2024
2.2.6 78 4/10/2024
2.2.5 98 3/26/2024
2.2.4 91 3/25/2024
2.2.3 90 3/24/2024
2.2.2 96 3/21/2024
2.2.1 101 3/20/2024
2.2.0 98 3/13/2024
2.1.9 95 2/21/2024
2.1.8 96 2/18/2024
2.1.7 89 2/16/2024
2.1.6 92 2/14/2024
2.1.5 98 2/14/2024
2.1.4 105 2/9/2024
2.1.3 119 2/8/2024
2.1.2 83 2/5/2024
2.1.1.2 159 12/26/2023
2.1.1.1 96 12/26/2023
2.1.1 111 12/25/2023
2.1.0 108 12/17/2023
2.0.11 123 12/6/2023
2.0.1 133 11/15/2023
2.0.0 107 11/14/2023
1.9.1 113 11/1/2023
1.9.0 107 10/19/2023
1.9.0-preview2 88 10/12/2023
1.9.0-preview1 88 10/12/2023
1.8.9 117 10/11/2023
1.8.8 108 10/11/2023
1.8.7-rc2 91 9/21/2023
1.8.7-rc1 93 9/12/2023
1.8.6 139 8/31/2023
1.8.5 119 8/25/2023
1.8.4 132 8/24/2023
1.8.3 135 8/23/2023
1.8.2 132 8/22/2023
1.8.1 138 8/18/2023
1.8.0 146 8/15/2023
1.7.9 163 8/11/2023
1.7.8 145 8/11/2023
1.7.7 149 8/10/2023
1.7.6 164 8/9/2023
1.7.5 134 8/9/2023
1.7.4 145 8/3/2023
1.7.3 151 8/1/2023
1.7.2 143 7/31/2023
1.7.1 137 7/27/2023
1.7.0 149 7/27/2023