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.
<PackageVersion Include="EasilyNET.MongoDistributedLock.AspNetCore" Version="1.7.6" />
                    
Directory.Packages.props
<PackageReference Include="EasilyNET.MongoDistributedLock.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package EasilyNET.MongoDistributedLock.AspNetCore@1.7.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EasilyNET.MongoDistributedLock.AspNetCore&version=1.7.6
                    
Install as a Cake Addin
#tool nuget:?package=EasilyNET.MongoDistributedLock.AspNetCore&version=1.7.6
                    
Install as a Cake Tool
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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.1113.100 158 11/13/2024
3.24.1112.125 128 11/12/2024
3.24.1107.140 133 11/7/2024
3.24.1107.54 132 11/7/2024
3.24.1107.34 141 11/7/2024
3.24.1105.111 130 11/5/2024
3.24.1103.31 147 11/2/2024
3.24.1103 140 11/2/2024
3.24.1031.135 137 10/31/2024
3.24.1031.112 120 10/31/2024
3.24.1031.104 133 10/31/2024
3.24.1029.142 132 10/29/2024
3.24.1025.30 142 10/24/2024
3.24.1022.142 113 10/22/2024
3.24.1018.204 186 10/18/2024
3.24.1018.175 182 10/18/2024
3.24.1018.166 168 10/18/2024
3.24.1018.93 179 10/18/2024
3.24.1017.42 122 10/16/2024
3.24.1016.161 129 10/16/2024
3.24.1015.231 127 10/15/2024
3.24.1015.14 128 10/14/2024
3.24.1012.114 128 10/12/2024
3.24.1009.115 138 10/9/2024
3.24.1008.160 126 10/8/2024
3.24.1008.133 135 10/8/2024
3.24.1007.185 135 10/7/2024
3.24.1003.33 133 10/2/2024
3.24.1002.162 159 10/2/2024
3.24.929.143 151 9/29/2024
3.24.929.141 128 9/29/2024
3.24.929.131 140 9/29/2024
3.24.929.122 124 9/29/2024
3.24.926.184 128 9/26/2024
3.24.926.182 130 9/26/2024
3.24.926.175 148 9/26/2024
3.24.924.160 140 9/24/2024
3.24.924.133 147 9/24/2024
3.24.924.124 136 9/24/2024
3.24.924.10 143 9/23/2024
3.24.924.1 136 9/23/2024
3.24.923.234 156 9/23/2024
3.24.923.232 167 9/23/2024
3.24.923.155 136 9/23/2024
3.24.919.92 150 9/19/2024
3.24.914.125 155 9/14/2024
3.24.914.115 159 9/14/2024
3.24.914.111 141 9/14/2024
3.24.911.95 153 9/11/2024
3.24.908.215 124 9/8/2024
3.24.904.200 137 9/4/2024
3.24.828.163 156 8/28/2024
3.24.820.173 140 8/20/2024
3.24.814.92 158 8/14/2024
3.24.812.115 153 8/12/2024
3.24.802.100 119 8/2/2024
3.24.801.162 123 8/1/2024
3.24.801.160 132 8/1/2024
3.24.801.155 130 8/1/2024
3.24.730.164 119 7/30/2024
3.24.730.91 115 7/30/2024
3.24.724.91 118 7/24/2024
3.24.718.105 155 7/18/2024
3.24.716.95 148 7/16/2024
3.24.712.94 138 7/12/2024
3.24.710.14 162 7/9/2024
3.24.709.105 156 7/9/2024
3.24.704.94 159 7/4/2024
3.24.701.90 170 7/1/2024
3.24.628.114 153 6/28/2024
3.24.627.145 158 6/27/2024
3.24.620.160 141 6/20/2024
3.24.613.115 158 6/13/2024
3.24.612.95 141 6/12/2024
3.24.528.90 154 5/28/2024
3.24.522.84 173 5/22/2024
3.24.512.213 145 5/12/2024
3.24.508.112 162 5/8/2024
2.2024.428.71 158 4/28/2024
2.2024.427.1128 156 4/27/2024
2.2.72 172 4/14/2024
2.2.71 160 4/12/2024
2.2.8 152 4/26/2024
2.2.6 151 4/10/2024
2.2.5 166 3/26/2024
2.2.4 175 3/25/2024
2.2.3 173 3/24/2024
2.2.2 170 3/21/2024
2.2.1 172 3/20/2024
2.2.0 163 3/13/2024
2.1.9 166 2/21/2024
2.1.8 167 2/18/2024
2.1.7 157 2/16/2024
2.1.6 158 2/14/2024
2.1.5 164 2/14/2024
2.1.4 184 2/9/2024
2.1.3 199 2/8/2024
2.1.2 150 2/5/2024
2.1.1.2 227 12/26/2023
2.1.1.1 158 12/26/2023
2.1.1 182 12/25/2023
2.1.0 178 12/17/2023
2.0.11 183 12/6/2023
2.0.1 181 11/15/2023
2.0.0 162 11/14/2023
1.9.1 180 11/1/2023
1.9.0 166 10/19/2023
1.9.0-preview2 161 10/12/2023
1.9.0-preview1 141 10/12/2023
1.8.9 187 10/11/2023
1.8.8 172 10/11/2023
1.8.7-rc2 152 9/21/2023
1.8.7-rc1 149 9/12/2023
1.8.6 209 8/31/2023
1.8.5 203 8/25/2023
1.8.4 204 8/24/2023
1.8.3 214 8/23/2023
1.8.2 218 8/22/2023
1.8.1 213 8/18/2023
1.8.0 234 8/15/2023
1.7.9 237 8/11/2023
1.7.8 229 8/11/2023
1.7.7 222 8/10/2023
1.7.6 243 8/9/2023
1.7.5 222 8/9/2023
1.7.4 231 8/3/2023
1.7.3 225 8/1/2023
1.7.2 231 7/31/2023
1.7.1 217 7/27/2023
1.7.0 229 7/27/2023