Soenneker.Utils.SingletonDictionary 2.1.423

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.SingletonDictionary --version 2.1.423                
NuGet\Install-Package Soenneker.Utils.SingletonDictionary -Version 2.1.423                
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="Soenneker.Utils.SingletonDictionary" Version="2.1.423" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.SingletonDictionary --version 2.1.423                
#r "nuget: Soenneker.Utils.SingletonDictionary, 2.1.423"                
#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 Soenneker.Utils.SingletonDictionary as a Cake Addin
#addin nuget:?package=Soenneker.Utils.SingletonDictionary&version=2.1.423

// Install Soenneker.Utils.SingletonDictionary as a Cake Tool
#tool nuget:?package=Soenneker.Utils.SingletonDictionary&version=2.1.423                

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.SingletonDictionary

An externally initializing singleton dictionary that uses double-check asynchronous locking, with optional async and sync disposal

Installation

dotnet add package Soenneker.Utils.SingletonDictionary

Example

Below is a long-living HttpClient implementation using SingletonDictionary with different settings. It guarantees only one instance of a particular key is instantiated due to the locking.

public class HttpRequester : IDisposable, IAsyncDisposable
{
    private readonly SingletonDictionary<HttpClient> _clients;

    public HttpRequester()
    {
        // This func will lazily execute once it's retrieved the first time.
        // Other threads calling this at the same moment will asynchronously wait,
        // and then utilize the HttpClient that was created from the first caller.
        _clients = new SingletonDictionary<HttpClient>((args) =>
        {
            var socketsHandler = new SocketsHttpHandler
            {
                PooledConnectionLifetime = TimeSpan.FromMinutes(10),
                MaxConnectionsPerServer = 10
            };

            HttpClient client = new HttpClient(socketsHandler);
            client.Timeout = TimeSpan.FromSeconds((int)args[0]);

            return client;
        });
    }

    public async ValueTask Get()
    {
        // retrieve the singleton async, thus not blocking the calling thread
        await (await _client.Get("100", 100)).GetAsync("https://google.com");
    }

    // Disposal is not necessary for AsyncSingleton unless the type used is IDisposable/IAsyncDisposable
    public ValueTask DisposeAsync()
    {
        GC.SuppressFinalize(false);

        return _client.DisposeAsync();
    }

    public void Dispose()
    {
        GC.SuppressFinalize(false);
        
        _client.Dispose();
    }
}
Product Compatible and additional computed target framework versions.
.NET 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 (6)

Showing the top 5 NuGet packages that depend on Soenneker.Utils.SingletonDictionary:

Package Downloads
Soenneker.Utils.HttpClientCache

Providing thread-safe singleton HttpClients

Soenneker.Cosmos.Database

A utility library for storing Azure Cosmos databases

Soenneker.ServiceBus.Sender

A utility library that holds Azure Service senders

Soenneker.Google.Credentials

An async thread-safe singleton for Google OAuth credentials

Soenneker.Blazor.Utils.ModuleImport

A Blazor utility library assisting with asynchronous module loading

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.450 3 9/16/2024
2.1.449 42 9/16/2024
2.1.448 1,435 9/12/2024
2.1.447 1,378 9/12/2024
2.1.446 656 9/11/2024
2.1.445 801 9/11/2024
2.1.443 2,217 9/11/2024
2.1.442 604 9/11/2024
2.1.441 589 9/11/2024
2.1.440 1,460 9/11/2024
2.1.439 4,966 9/10/2024
2.1.438 79 9/10/2024
2.1.437 807 9/10/2024
2.1.436 71 9/10/2024
2.1.434 2,038 9/10/2024
2.1.433 424 9/9/2024
2.1.432 1,553 9/9/2024
2.1.430 1,116 9/9/2024
2.1.428 72 9/9/2024
2.1.427 339 9/9/2024
2.1.426 9,890 9/7/2024
2.1.425 85 9/7/2024
2.1.424 3,717 9/6/2024
2.1.423 258 9/6/2024
2.1.422 1,636 9/6/2024
2.1.421 71 9/5/2024
2.1.420 78 9/5/2024
2.1.419 1,782 9/5/2024
2.1.418 849 9/5/2024
2.1.417 70 9/5/2024
2.1.416 855 9/5/2024
2.1.415 292 9/5/2024
2.1.414 67 9/5/2024
2.1.413 3,795 9/5/2024
2.1.412 132 9/5/2024
2.1.411 72 9/5/2024
2.1.410 1,665 9/4/2024
2.1.409 6,002 9/3/2024
2.1.408 66 9/3/2024
2.1.407 59 9/3/2024
2.1.406 2,929 9/3/2024
2.1.405 92 9/3/2024
2.1.404 1,798 9/3/2024
2.1.403 3,896 8/29/2024
2.1.402 1,828 8/29/2024
2.1.401 2,128 8/26/2024
2.1.400 69 8/26/2024
2.1.399 3,604 8/21/2024
2.1.398 436 8/21/2024
2.1.397 89 8/21/2024
2.1.396 1,845 8/21/2024
2.1.395 102 8/20/2024
2.1.394 87 8/20/2024
2.1.393 334 8/20/2024
2.1.392 2,120 8/20/2024
2.1.391 285 8/20/2024
2.1.390 81 8/20/2024
2.1.389 1,919 8/20/2024
2.1.388 81 8/20/2024
2.1.387 838 8/20/2024
2.1.386 2,090 8/19/2024
2.1.385 3,509 8/15/2024
2.1.384 1,542 8/15/2024
2.1.383 3,559 8/14/2024
2.1.382 111 8/13/2024
2.1.381 4,130 8/7/2024
2.1.380 189 8/6/2024
2.1.379 1,935 8/6/2024
2.1.378 3,444 8/1/2024
2.1.377 218 8/1/2024
2.1.376 65 8/1/2024
2.1.374 752 8/1/2024
2.1.373 3,960 7/25/2024
2.1.372 55 7/25/2024
2.1.371 478 7/25/2024
2.1.370 209 7/25/2024
2.1.369 231 7/25/2024
2.1.368 119 7/25/2024
2.1.367 256 7/24/2024
2.1.366 93 7/24/2024
2.1.365 132 7/24/2024
2.1.364 209 7/24/2024
2.1.363 5,469 7/20/2024
2.1.362 988 7/20/2024
2.1.361 3,507 7/14/2024
2.1.360 1,081 7/14/2024
2.1.359 72 7/14/2024
2.1.358 1,051 7/14/2024
2.1.357 3,067 7/10/2024
2.1.355 594 7/10/2024
2.1.354 831 7/10/2024
2.1.353 82 7/10/2024
2.1.352 1,480 7/10/2024
2.1.351 83 7/10/2024
2.1.350 68 7/10/2024
2.1.349 113 7/10/2024
2.1.348 70 7/10/2024
2.1.347 1,442 7/10/2024
2.1.346 88 7/10/2024
2.1.345 570 7/10/2024
2.1.344 77 7/10/2024
2.1.343 142 7/9/2024
2.1.342 76 7/9/2024
2.1.339 1,466 7/9/2024
2.1.338 354 7/9/2024
2.1.337 2,942 7/9/2024
2.1.336 747 7/9/2024
2.1.335 79 7/9/2024
2.1.334 1,797 7/9/2024
2.1.333 81 7/9/2024
2.1.332 1,041 7/9/2024
2.1.331 69 7/9/2024
2.1.330 1,775 7/9/2024
2.1.329 71 7/9/2024
2.1.328 768 7/9/2024
2.1.327 495 7/8/2024
2.1.326 670 7/8/2024
2.1.325 84 7/8/2024
2.1.324 79 7/8/2024
2.1.323 3,476 7/8/2024
2.1.322 1,116 7/8/2024
2.1.321 84 7/8/2024
2.1.320 1,597 7/7/2024
2.1.319 85 7/7/2024
2.1.318 87 7/7/2024
2.1.317 75 7/7/2024
2.1.316 799 7/7/2024
2.1.315 1,533 7/7/2024
2.1.314 1,291 7/7/2024
2.1.313 146 7/7/2024
2.1.312 2,396 7/5/2024
2.1.311 2,712 7/3/2024
2.1.310 2,127 7/3/2024
2.1.309 242 7/3/2024
2.1.308 2,712 7/2/2024
2.1.307 1,323 6/30/2024
2.1.306 1,577 6/28/2024
2.1.305 3,898 6/22/2024
2.1.304 3,541 6/15/2024
2.1.303 2,970 6/14/2024
2.1.302 4,324 6/1/2024
2.1.301 1,144 6/1/2024
2.1.300 413 6/1/2024
2.1.299 4,244 5/31/2024
2.1.298 2,687 5/29/2024
2.1.297 2,173 5/28/2024
2.1.296 1,744 5/27/2024
2.1.295 3,513 5/26/2024
2.1.294 1,460 5/26/2024
2.1.293 330 5/26/2024
2.1.292 1,804 5/25/2024
2.1.291 983 5/25/2024
2.1.290 89 5/25/2024
2.1.289 88 5/25/2024
2.1.288 483 5/25/2024
2.1.287 89 5/25/2024
2.1.286 290 5/25/2024
2.1.285 93 5/25/2024
2.1.284 89 5/25/2024
2.1.283 5,373 5/23/2024
2.1.282 367 5/23/2024
2.1.281 189 5/22/2024
2.1.280 2,613 5/22/2024
2.1.279 92 5/22/2024
2.1.278 90 5/22/2024
2.1.277 91 5/22/2024
2.1.276 1,500 5/22/2024
2.1.275 2,426 5/18/2024
2.1.274 1,367 5/18/2024
2.1.273 1,292 5/17/2024
2.1.272 76 5/17/2024
2.1.271 1,963 5/16/2024
2.1.270 306 5/15/2024
2.1.269 1,957 5/15/2024
2.1.268 3,160 5/12/2024
2.1.267 1,966 5/3/2024
2.1.266 785 4/30/2024
2.1.265 1,265 4/29/2024
2.1.264 1,399 4/29/2024
2.1.263 1,884 4/28/2024
2.1.262 1,054 4/28/2024
2.1.261 790 4/28/2024
2.1.260 1,282 4/28/2024
2.1.259 634 4/28/2024
2.1.258 79 4/28/2024
2.1.257 3,049 4/27/2024
2.1.256 80 4/27/2024
2.1.255 3,203 4/19/2024
2.1.254 2,944 4/18/2024
2.1.253 2,512 4/12/2024
2.1.252 806 4/12/2024
2.1.251 522 4/12/2024
2.1.250 618 4/12/2024
2.1.249 134 4/12/2024
2.1.248 76 4/12/2024
2.1.247 712 4/12/2024
2.1.246 209 4/12/2024
2.1.245 1,189 4/11/2024
2.1.244 2,627 4/10/2024
2.1.243 822 4/9/2024
2.1.242 2,239 4/2/2024
2.1.241 638 4/1/2024
2.1.240 1,461 3/29/2024
2.1.239 1,317 3/25/2024
2.1.238 214 3/25/2024
2.1.237 2,393 3/20/2024
2.1.236 1,531 3/19/2024
2.1.235 392 3/19/2024
2.1.234 1,660 3/18/2024
2.1.233 1,039 3/18/2024
2.1.232 1,018 3/15/2024
2.1.231 1,723 3/13/2024
2.1.230 813 3/13/2024
2.1.229 451 3/13/2024
2.1.228 560 3/13/2024
2.1.227 94 3/13/2024
2.1.226 391 3/13/2024
2.1.225 103 3/13/2024
2.1.224 93 3/13/2024
2.1.223 1,168 3/12/2024
2.1.222 2,015 3/11/2024
2.1.221 1,747 3/11/2024
2.1.220 1,181 3/10/2024
2.1.219 1,376 3/8/2024
2.1.218 770 3/8/2024
2.1.217 1,128 3/8/2024
2.1.216 1,520 3/6/2024
2.1.215 1,488 3/4/2024
2.1.214 1,023 3/4/2024
2.1.213 1,857 3/2/2024
2.1.212 867 3/2/2024
2.1.211 292 3/2/2024
2.1.210 244 3/2/2024
2.1.209 307 3/2/2024
2.1.208 2,556 2/29/2024
2.1.207 462 2/29/2024
2.1.206 229 2/29/2024
2.1.205 2,475 2/26/2024
2.1.204 1,104 2/25/2024
2.1.203 1,980 2/23/2024
2.1.202 1,444 2/22/2024
2.1.201 719 2/22/2024
2.1.200 297 2/21/2024
2.1.199 910 2/21/2024
2.1.198 213 2/21/2024
2.1.197 619 2/21/2024
2.1.196 102 2/21/2024
2.1.195 864 2/21/2024
2.1.194 304 2/21/2024
2.1.193 93 2/21/2024
2.1.192 93 2/21/2024
2.1.191 463 2/21/2024
2.1.190 76 2/21/2024
2.1.189 1,919 2/20/2024
2.1.188 568 2/20/2024
2.1.187 484 2/20/2024
2.1.186 494 2/20/2024
2.1.185 1,566 2/19/2024
2.1.184 1,384 2/17/2024
2.1.183 651 2/16/2024
2.1.182 670 2/16/2024
2.1.181 956 2/16/2024
2.1.180 81 2/16/2024
2.1.179 440 2/16/2024
2.1.178 75 2/16/2024
2.1.177 92 2/16/2024
2.1.176 404 2/16/2024
2.1.175 79 2/16/2024
2.1.174 2,491 2/13/2024
2.1.173 1,013 2/13/2024
2.1.172 824 2/13/2024
2.1.171 319 2/13/2024
2.1.170 464 2/13/2024
2.1.169 1,456 2/12/2024
2.1.168 403 2/11/2024
2.1.167 1,165 2/11/2024
2.1.166 661 2/11/2024
2.1.165 2,023 2/10/2024
2.1.164 423 2/9/2024
2.1.163 80 2/9/2024
2.1.162 1,145 2/9/2024
2.1.161 1,245 2/9/2024
2.1.160 269 2/8/2024
2.1.159 894 2/8/2024
2.1.158 658 2/8/2024
2.1.157 1,086 2/8/2024
2.1.156 81 2/8/2024
2.1.155 1,409 2/7/2024
2.1.154 326 2/7/2024
2.1.153 463 2/7/2024
2.1.152 940 2/7/2024
2.1.151 281 2/6/2024
2.1.150 91 2/6/2024
2.1.149 78 2/6/2024
2.1.148 2,105 2/5/2024
2.1.147 1,130 2/4/2024
2.1.146 1,537 2/2/2024
2.1.145 1,492 1/31/2024
2.1.144 1,638 1/29/2024
2.1.143 1,036 1/29/2024
2.1.142 261 1/29/2024
2.1.141 1,155 1/28/2024
2.1.140 346 1/28/2024
2.1.139 227 1/28/2024
2.1.138 428 1/28/2024
2.1.137 1,443 1/28/2024
2.1.136 693 1/28/2024
2.1.135 205 1/27/2024
2.1.134 728 1/27/2024
2.1.133 792 1/27/2024
2.1.132 894 1/27/2024
2.1.131 108 1/27/2024
2.1.130 566 1/27/2024
2.1.129 759 1/26/2024
2.1.128 149 1/26/2024
2.1.127 688 1/26/2024
2.1.126 809 1/26/2024
2.1.125 1,279 1/26/2024
2.1.124 624 1/25/2024
2.1.123 889 1/25/2024
2.1.122 351 1/25/2024
2.1.121 725 1/25/2024
2.1.120 407 1/25/2024
2.1.119 1,933 1/19/2024
2.1.118 1,736 1/15/2024
2.1.117 400 1/15/2024
2.1.116 909 1/15/2024
2.1.115 96 1/15/2024
2.1.114 443 1/15/2024
2.1.113 1,058 1/15/2024
2.1.112 2,015 1/14/2024
2.1.111 1,238 1/13/2024
2.1.110 1,482 1/12/2024
2.1.109 1,592 1/11/2024
2.1.108 2,102 1/7/2024
2.1.107 1,716 1/5/2024
2.1.106 345 1/5/2024
2.1.105 106 1/5/2024
2.1.104 100 1/5/2024
2.1.103 1,173 1/5/2024
2.1.102 113 1/5/2024
2.1.101 2,130 1/1/2024
2.1.100 1,734 12/28/2023
2.1.99 567 12/28/2023
2.1.98 369 12/28/2023
2.1.97 103 12/28/2023
2.1.96 101 12/28/2023
2.1.95 566 12/27/2023
2.1.94 95 12/27/2023
2.1.93 347 12/27/2023
2.1.92 88 12/27/2023
2.1.91 95 12/27/2023
2.1.90 1,593 12/25/2023
2.1.89 268 12/25/2023
2.1.88 487 12/25/2023
2.1.87 94 12/25/2023
2.1.86 451 12/25/2023
2.1.85 101 12/25/2023
2.1.84 390 12/25/2023
2.1.83 93 12/25/2023
2.1.82 1,122 12/24/2023
2.1.81 790 12/23/2023
2.1.80 552 12/23/2023
2.1.79 240 12/23/2023
2.1.78 412 12/23/2023
2.1.77 100 12/23/2023
2.1.76 90 12/23/2023
2.1.75 748 12/23/2023
2.1.74 89 12/23/2023
2.1.73 973 12/19/2023
2.1.72 160 12/19/2023
2.1.71 2,183 12/11/2023
2.1.70 520 12/10/2023
2.1.69 98 12/10/2023
2.1.68 382 12/10/2023
2.1.67 999 12/10/2023
2.1.66 254 12/9/2023
2.1.65 273 12/9/2023
2.1.64 215 12/9/2023
2.1.63 96 12/9/2023
2.1.62 203 12/9/2023
2.1.61 146 12/9/2023
2.1.60 94 12/9/2023
2.1.59 765 12/9/2023
2.1.58 98 12/9/2023
2.1.57 1,076 12/6/2023
2.1.56 262 12/6/2023
2.1.55 146 12/6/2023
2.1.54 209 12/6/2023
2.1.53 621 12/5/2023
2.1.52 264 12/5/2023
2.1.51 253 12/5/2023
2.1.50 257 12/5/2023
2.1.49 99 12/5/2023
2.1.48 262 12/5/2023
2.1.47 206 12/5/2023
2.1.46 102 12/4/2023
2.1.45 107 12/4/2023
2.1.44 260 12/4/2023
2.1.43 110 12/4/2023
2.1.42 601 12/4/2023
2.1.41 88 12/4/2023
2.1.40 808 11/27/2023
2.1.39 330 11/26/2023
2.1.38 137 11/26/2023
2.1.37 363 11/23/2023
2.1.36 452 11/23/2023
2.1.35 433 11/23/2023
2.1.34 106 11/23/2023
2.1.33 217 11/23/2023
2.1.32 91 11/23/2023
2.1.31 715 11/20/2023
2.1.30 613 11/20/2023
2.1.29 491 11/19/2023
2.1.28 153 11/19/2023
2.1.27 316 11/19/2023
2.1.26 297 11/19/2023
2.1.25 293 11/19/2023
2.1.24 94 11/19/2023
2.1.23 158 11/18/2023
2.1.22 632 11/18/2023
2.1.21 242 11/18/2023
2.1.20 334 11/18/2023
2.1.19 101 11/18/2023
2.1.18 186 11/18/2023
2.1.17 101 11/18/2023
2.1.16 363 11/17/2023
2.1.15 308 11/17/2023
2.1.14 99 11/17/2023
2.1.13 303 11/17/2023
2.1.12 195 11/17/2023
2.1.11 295 11/17/2023
2.1.10 94 11/17/2023
2.1.9 292 11/17/2023
2.1.8 97 11/17/2023
2.1.7 103 11/17/2023
2.1.6 227 11/17/2023
2.1.5 210 11/16/2023
2.0.101 1,265 11/15/2023
2.0.100 90 11/15/2023
2.0.99 96 11/15/2023
2.0.4 99 11/16/2023
2.0.3 101 11/16/2023
2.0.2 98 11/16/2023
2.0.1 96 11/16/2023
1.0.98 416 11/14/2023
1.0.97 543 11/13/2023
1.0.96 91 11/13/2023
1.0.95 436 11/10/2023
1.0.94 93 11/10/2023
1.0.93 577 11/9/2023
1.0.92 95 11/9/2023
1.0.91 673 11/7/2023
1.0.90 89 11/7/2023
1.0.89 358 11/6/2023
1.0.88 94 11/6/2023
1.0.87 450 11/3/2023
1.0.86 106 11/3/2023
1.0.85 584 11/2/2023
1.0.84 97 11/2/2023
1.0.83 448 11/1/2023
1.0.82 996 10/26/2023
1.0.81 881 10/19/2023
1.0.80 107 10/19/2023
1.0.79 544 10/18/2023
1.0.78 124 10/18/2023
1.0.77 496 10/17/2023
1.0.76 110 10/17/2023
1.0.75 461 10/16/2023
1.0.74 117 10/16/2023
1.0.73 502 10/13/2023
1.0.72 259 10/12/2023
1.0.71 1,234 9/20/2023
1.0.70 426 9/19/2023
1.0.69 454 9/18/2023
1.0.68 106 9/18/2023
1.0.67 623 9/14/2023
1.0.66 1,068 8/31/2023
1.0.65 116 8/31/2023
1.0.64 550 8/30/2023
1.0.63 121 8/30/2023
1.0.62 125 8/30/2023
1.0.61 624 8/28/2023
1.0.60 512 8/25/2023
1.0.59 120 8/25/2023
1.0.58 351 8/24/2023
1.0.57 984 8/21/2023
1.0.56 556 8/18/2023
1.0.55 528 8/17/2023
1.0.54 123 8/17/2023
1.0.53 1,393 8/10/2023
1.0.52 426 8/9/2023
1.0.51 515 8/8/2023
1.0.50 484 8/7/2023
1.0.49 142 8/7/2023
1.0.48 1,751 7/13/2023
1.0.47 672 7/11/2023
1.0.46 565 7/10/2023
1.0.45 544 7/7/2023
1.0.44 137 7/7/2023
1.0.43 1,517 6/30/2023
1.0.42 801 6/29/2023
1.0.41 467 6/28/2023
1.0.40 1,156 6/26/2023
1.0.39 557 6/23/2023
1.0.38 806 6/21/2023
1.0.37 1,063 6/15/2023
1.0.36 355 6/14/2023
1.0.35 1,336 6/9/2023
1.0.34 664 6/8/2023
1.0.33 1,258 6/7/2023
1.0.32 134 6/7/2023
1.0.31 971 6/6/2023
1.0.30 915 6/5/2023
1.0.29 1,113 6/2/2023
1.0.28 124 6/2/2023
1.0.27 1,030 6/1/2023
1.0.26 494 5/31/2023
1.0.25 384 5/31/2023
1.0.24 124 5/31/2023
1.0.23 1,224 5/30/2023
1.0.22 1,272 5/26/2023
1.0.21 550 5/25/2023
1.0.20 120 5/25/2023
1.0.19 680 5/24/2023
1.0.18 122 5/24/2023
1.0.17 357 5/23/2023
1.0.13 1,188 5/22/2023
1.0.12 969 5/18/2023
1.0.11 475 5/17/2023
1.0.10 1,313 5/1/2023
1.0.9 846 4/25/2023
1.0.8 405 4/24/2023
1.0.7 872 4/21/2023
1.0.6 1,665 4/13/2023
1.0.5 500 4/12/2023
1.0.4 841 4/8/2023
1.0.3 168 4/8/2023
1.0.2 500 4/8/2023
1.0.1 159 4/8/2023