Soenneker.Utils.SingletonDictionary 2.1.354

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.354                
NuGet\Install-Package Soenneker.Utils.SingletonDictionary -Version 2.1.354                
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.354" />                
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.354                
#r "nuget: Soenneker.Utils.SingletonDictionary, 2.1.354"                
#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.354

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

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.426 433 9/7/2024
2.1.425 26 9/7/2024
2.1.424 1,601 9/6/2024
2.1.423 119 9/6/2024
2.1.422 724 9/6/2024
2.1.421 31 9/5/2024
2.1.420 25 9/5/2024
2.1.419 821 9/5/2024
2.1.418 385 9/5/2024
2.1.417 25 9/5/2024
2.1.416 438 9/5/2024
2.1.415 129 9/5/2024
2.1.414 23 9/5/2024
2.1.413 1,715 9/5/2024
2.1.412 71 9/5/2024
2.1.411 37 9/5/2024
2.1.410 781 9/4/2024
2.1.409 3,486 9/3/2024
2.1.408 59 9/3/2024
2.1.407 52 9/3/2024
2.1.406 2,017 9/3/2024
2.1.405 85 9/3/2024
2.1.404 1,483 9/3/2024
2.1.403 3,149 8/29/2024
2.1.402 1,821 8/29/2024
2.1.401 2,113 8/26/2024
2.1.400 62 8/26/2024
2.1.399 3,583 8/21/2024
2.1.398 413 8/21/2024
2.1.397 69 8/21/2024
2.1.396 1,822 8/21/2024
2.1.395 79 8/20/2024
2.1.394 64 8/20/2024
2.1.393 312 8/20/2024
2.1.392 2,101 8/20/2024
2.1.391 265 8/20/2024
2.1.390 61 8/20/2024
2.1.389 1,898 8/20/2024
2.1.388 60 8/20/2024
2.1.387 816 8/20/2024
2.1.386 2,071 8/19/2024
2.1.385 3,489 8/15/2024
2.1.384 1,520 8/15/2024
2.1.383 3,541 8/14/2024
2.1.382 90 8/13/2024
2.1.381 4,120 8/7/2024
2.1.380 187 8/6/2024
2.1.379 1,931 8/6/2024
2.1.378 3,440 8/1/2024
2.1.377 214 8/1/2024
2.1.376 60 8/1/2024
2.1.374 747 8/1/2024
2.1.373 3,956 7/25/2024
2.1.372 51 7/25/2024
2.1.371 474 7/25/2024
2.1.370 205 7/25/2024
2.1.369 226 7/25/2024
2.1.368 114 7/25/2024
2.1.367 251 7/24/2024
2.1.366 89 7/24/2024
2.1.365 128 7/24/2024
2.1.364 205 7/24/2024
2.1.363 5,450 7/20/2024
2.1.362 983 7/20/2024
2.1.361 3,499 7/14/2024
2.1.360 1,076 7/14/2024
2.1.359 67 7/14/2024
2.1.358 1,047 7/14/2024
2.1.357 3,061 7/10/2024
2.1.355 590 7/10/2024
2.1.354 827 7/10/2024
2.1.353 78 7/10/2024
2.1.352 1,476 7/10/2024
2.1.351 81 7/10/2024
2.1.350 66 7/10/2024
2.1.349 111 7/10/2024
2.1.348 68 7/10/2024
2.1.347 1,438 7/10/2024
2.1.346 84 7/10/2024
2.1.345 564 7/10/2024
2.1.344 73 7/10/2024
2.1.343 137 7/9/2024
2.1.342 71 7/9/2024
2.1.339 1,461 7/9/2024
2.1.338 349 7/9/2024
2.1.337 2,937 7/9/2024
2.1.336 741 7/9/2024
2.1.335 75 7/9/2024
2.1.334 1,793 7/9/2024
2.1.333 77 7/9/2024
2.1.332 807 7/9/2024
2.1.331 65 7/9/2024
2.1.330 1,771 7/9/2024
2.1.329 67 7/9/2024
2.1.328 764 7/9/2024
2.1.327 491 7/8/2024
2.1.326 664 7/8/2024
2.1.325 80 7/8/2024
2.1.324 75 7/8/2024
2.1.323 3,472 7/8/2024
2.1.322 1,110 7/8/2024
2.1.321 80 7/8/2024
2.1.320 1,593 7/7/2024
2.1.319 81 7/7/2024
2.1.318 83 7/7/2024
2.1.317 71 7/7/2024
2.1.316 795 7/7/2024
2.1.315 1,529 7/7/2024
2.1.314 1,286 7/7/2024
2.1.313 141 7/7/2024
2.1.312 2,391 7/5/2024
2.1.311 2,707 7/3/2024
2.1.310 2,122 7/3/2024
2.1.309 237 7/3/2024
2.1.308 2,707 7/2/2024
2.1.307 1,318 6/30/2024
2.1.306 1,572 6/28/2024
2.1.305 3,893 6/22/2024
2.1.304 3,536 6/15/2024
2.1.303 2,961 6/14/2024
2.1.302 4,319 6/1/2024
2.1.301 1,140 6/1/2024
2.1.300 409 6/1/2024
2.1.299 4,238 5/31/2024
2.1.298 2,683 5/29/2024
2.1.297 2,169 5/28/2024
2.1.296 1,740 5/27/2024
2.1.295 3,509 5/26/2024
2.1.294 1,456 5/26/2024
2.1.293 326 5/26/2024
2.1.292 1,800 5/25/2024
2.1.291 979 5/25/2024
2.1.290 85 5/25/2024
2.1.289 84 5/25/2024
2.1.288 479 5/25/2024
2.1.287 85 5/25/2024
2.1.286 285 5/25/2024
2.1.285 88 5/25/2024
2.1.284 85 5/25/2024
2.1.283 5,369 5/23/2024
2.1.282 363 5/23/2024
2.1.281 184 5/22/2024
2.1.280 2,609 5/22/2024
2.1.279 88 5/22/2024
2.1.278 86 5/22/2024
2.1.277 87 5/22/2024
2.1.276 1,496 5/22/2024
2.1.275 2,423 5/18/2024
2.1.274 1,364 5/18/2024
2.1.273 1,289 5/17/2024
2.1.272 73 5/17/2024
2.1.271 1,960 5/16/2024
2.1.270 303 5/15/2024
2.1.269 1,954 5/15/2024
2.1.268 3,157 5/12/2024
2.1.267 1,963 5/3/2024
2.1.266 782 4/30/2024
2.1.265 1,262 4/29/2024
2.1.264 1,396 4/29/2024
2.1.263 1,881 4/28/2024
2.1.262 1,051 4/28/2024
2.1.261 787 4/28/2024
2.1.260 1,279 4/28/2024
2.1.259 630 4/28/2024
2.1.258 75 4/28/2024
2.1.257 3,046 4/27/2024
2.1.256 77 4/27/2024
2.1.255 3,199 4/19/2024
2.1.254 2,940 4/18/2024
2.1.253 2,508 4/12/2024
2.1.252 802 4/12/2024
2.1.251 517 4/12/2024
2.1.250 614 4/12/2024
2.1.249 130 4/12/2024
2.1.248 72 4/12/2024
2.1.247 708 4/12/2024
2.1.246 205 4/12/2024
2.1.245 1,178 4/11/2024
2.1.244 2,622 4/10/2024
2.1.243 817 4/9/2024
2.1.242 2,234 4/2/2024
2.1.241 634 4/1/2024
2.1.240 1,457 3/29/2024
2.1.239 1,315 3/25/2024
2.1.238 210 3/25/2024
2.1.237 2,390 3/20/2024
2.1.236 1,527 3/19/2024
2.1.235 388 3/19/2024
2.1.234 1,656 3/18/2024
2.1.233 1,035 3/18/2024
2.1.232 1,014 3/15/2024
2.1.231 1,719 3/13/2024
2.1.230 809 3/13/2024
2.1.229 447 3/13/2024
2.1.228 556 3/13/2024
2.1.227 90 3/13/2024
2.1.226 388 3/13/2024
2.1.225 100 3/13/2024
2.1.224 90 3/13/2024
2.1.223 1,165 3/12/2024
2.1.222 2,012 3/11/2024
2.1.221 1,744 3/11/2024
2.1.220 1,178 3/10/2024
2.1.219 1,373 3/8/2024
2.1.218 767 3/8/2024
2.1.217 1,125 3/8/2024
2.1.216 1,511 3/6/2024
2.1.215 1,485 3/4/2024
2.1.214 1,020 3/4/2024
2.1.213 1,854 3/2/2024
2.1.212 864 3/2/2024
2.1.211 289 3/2/2024
2.1.210 241 3/2/2024
2.1.209 302 3/2/2024
2.1.208 2,553 2/29/2024
2.1.207 459 2/29/2024
2.1.206 226 2/29/2024
2.1.205 2,472 2/26/2024
2.1.204 1,101 2/25/2024
2.1.203 1,977 2/23/2024
2.1.202 1,440 2/22/2024
2.1.201 715 2/22/2024
2.1.200 293 2/21/2024
2.1.199 906 2/21/2024
2.1.198 209 2/21/2024
2.1.197 616 2/21/2024
2.1.196 99 2/21/2024
2.1.195 861 2/21/2024
2.1.194 301 2/21/2024
2.1.193 90 2/21/2024
2.1.192 90 2/21/2024
2.1.191 460 2/21/2024
2.1.190 72 2/21/2024
2.1.189 1,915 2/20/2024
2.1.188 564 2/20/2024
2.1.187 480 2/20/2024
2.1.186 491 2/20/2024
2.1.185 1,561 2/19/2024
2.1.184 1,379 2/17/2024
2.1.183 646 2/16/2024
2.1.182 663 2/16/2024
2.1.181 951 2/16/2024
2.1.180 77 2/16/2024
2.1.179 436 2/16/2024
2.1.178 71 2/16/2024
2.1.177 87 2/16/2024
2.1.176 400 2/16/2024
2.1.175 74 2/16/2024
2.1.174 2,487 2/13/2024
2.1.173 1,009 2/13/2024
2.1.172 820 2/13/2024
2.1.171 315 2/13/2024
2.1.170 460 2/13/2024
2.1.169 1,452 2/12/2024
2.1.168 399 2/11/2024
2.1.167 1,161 2/11/2024
2.1.166 657 2/11/2024
2.1.165 2,014 2/10/2024
2.1.164 418 2/9/2024
2.1.163 74 2/9/2024
2.1.162 1,140 2/9/2024
2.1.161 1,241 2/9/2024
2.1.160 265 2/8/2024
2.1.159 890 2/8/2024
2.1.158 654 2/8/2024
2.1.157 1,082 2/8/2024
2.1.156 77 2/8/2024
2.1.155 1,405 2/7/2024
2.1.154 322 2/7/2024
2.1.153 459 2/7/2024
2.1.152 936 2/7/2024
2.1.151 277 2/6/2024
2.1.150 87 2/6/2024
2.1.149 74 2/6/2024
2.1.148 2,101 2/5/2024
2.1.147 1,126 2/4/2024
2.1.146 1,533 2/2/2024
2.1.145 1,487 1/31/2024
2.1.144 1,633 1/29/2024
2.1.143 1,032 1/29/2024
2.1.142 257 1/29/2024
2.1.141 1,150 1/28/2024
2.1.140 342 1/28/2024
2.1.139 223 1/28/2024
2.1.138 424 1/28/2024
2.1.137 1,439 1/28/2024
2.1.136 688 1/28/2024
2.1.135 201 1/27/2024
2.1.134 724 1/27/2024
2.1.133 788 1/27/2024
2.1.132 889 1/27/2024
2.1.131 103 1/27/2024
2.1.130 561 1/27/2024
2.1.129 754 1/26/2024
2.1.128 144 1/26/2024
2.1.127 684 1/26/2024
2.1.126 805 1/26/2024
2.1.125 1,275 1/26/2024
2.1.124 620 1/25/2024
2.1.123 885 1/25/2024
2.1.122 347 1/25/2024
2.1.121 720 1/25/2024
2.1.120 402 1/25/2024
2.1.119 1,928 1/19/2024
2.1.118 1,731 1/15/2024
2.1.117 394 1/15/2024
2.1.116 903 1/15/2024
2.1.115 90 1/15/2024
2.1.114 437 1/15/2024
2.1.113 1,052 1/15/2024
2.1.112 2,010 1/14/2024
2.1.111 1,233 1/13/2024
2.1.110 1,477 1/12/2024
2.1.109 1,588 1/11/2024
2.1.108 2,098 1/7/2024
2.1.107 1,712 1/5/2024
2.1.106 341 1/5/2024
2.1.105 102 1/5/2024
2.1.104 96 1/5/2024
2.1.103 1,169 1/5/2024
2.1.102 109 1/5/2024
2.1.101 2,126 1/1/2024
2.1.100 1,730 12/28/2023
2.1.99 563 12/28/2023
2.1.98 365 12/28/2023
2.1.97 99 12/28/2023
2.1.96 96 12/28/2023
2.1.95 561 12/27/2023
2.1.94 90 12/27/2023
2.1.93 343 12/27/2023
2.1.92 84 12/27/2023
2.1.91 91 12/27/2023
2.1.90 1,589 12/25/2023
2.1.89 264 12/25/2023
2.1.88 483 12/25/2023
2.1.87 90 12/25/2023
2.1.86 447 12/25/2023
2.1.85 97 12/25/2023
2.1.84 386 12/25/2023
2.1.83 89 12/25/2023
2.1.82 1,118 12/24/2023
2.1.81 786 12/23/2023
2.1.80 548 12/23/2023
2.1.79 236 12/23/2023
2.1.78 408 12/23/2023
2.1.77 96 12/23/2023
2.1.76 86 12/23/2023
2.1.75 744 12/23/2023
2.1.74 85 12/23/2023
2.1.73 969 12/19/2023
2.1.72 156 12/19/2023
2.1.71 2,179 12/11/2023
2.1.70 516 12/10/2023
2.1.69 94 12/10/2023
2.1.68 378 12/10/2023
2.1.67 995 12/10/2023
2.1.66 250 12/9/2023
2.1.65 268 12/9/2023
2.1.64 210 12/9/2023
2.1.63 92 12/9/2023
2.1.62 199 12/9/2023
2.1.61 141 12/9/2023
2.1.60 90 12/9/2023
2.1.59 761 12/9/2023
2.1.58 93 12/9/2023
2.1.57 1,071 12/6/2023
2.1.56 258 12/6/2023
2.1.55 142 12/6/2023
2.1.54 205 12/6/2023
2.1.53 616 12/5/2023
2.1.52 259 12/5/2023
2.1.51 249 12/5/2023
2.1.50 253 12/5/2023
2.1.49 95 12/5/2023
2.1.48 257 12/5/2023
2.1.47 201 12/5/2023
2.1.46 97 12/4/2023
2.1.45 96 12/4/2023
2.1.44 255 12/4/2023
2.1.43 105 12/4/2023
2.1.42 596 12/4/2023
2.1.41 84 12/4/2023
2.1.40 806 11/27/2023
2.1.39 325 11/26/2023
2.1.38 133 11/26/2023
2.1.37 358 11/23/2023
2.1.36 448 11/23/2023
2.1.35 429 11/23/2023
2.1.34 102 11/23/2023
2.1.33 213 11/23/2023
2.1.32 87 11/23/2023
2.1.31 711 11/20/2023
2.1.30 609 11/20/2023
2.1.29 487 11/19/2023
2.1.28 149 11/19/2023
2.1.27 312 11/19/2023
2.1.26 293 11/19/2023
2.1.25 289 11/19/2023
2.1.24 90 11/19/2023
2.1.23 154 11/18/2023
2.1.22 628 11/18/2023
2.1.21 238 11/18/2023
2.1.20 330 11/18/2023
2.1.19 97 11/18/2023
2.1.18 182 11/18/2023
2.1.17 97 11/18/2023
2.1.16 359 11/17/2023
2.1.15 304 11/17/2023
2.1.14 95 11/17/2023
2.1.13 299 11/17/2023
2.1.12 191 11/17/2023
2.1.11 291 11/17/2023
2.1.10 89 11/17/2023
2.1.9 287 11/17/2023
2.1.8 93 11/17/2023
2.1.7 99 11/17/2023
2.1.6 223 11/17/2023
2.1.5 200 11/16/2023
2.0.101 1,261 11/15/2023
2.0.100 86 11/15/2023
2.0.99 92 11/15/2023
2.0.4 94 11/16/2023
2.0.3 96 11/16/2023
2.0.2 94 11/16/2023
2.0.1 92 11/16/2023
1.0.98 412 11/14/2023
1.0.97 539 11/13/2023
1.0.96 86 11/13/2023
1.0.95 432 11/10/2023
1.0.94 88 11/10/2023
1.0.93 572 11/9/2023
1.0.92 91 11/9/2023
1.0.91 669 11/7/2023
1.0.90 85 11/7/2023
1.0.89 354 11/6/2023
1.0.88 90 11/6/2023
1.0.87 445 11/3/2023
1.0.86 101 11/3/2023
1.0.85 579 11/2/2023
1.0.84 92 11/2/2023
1.0.83 443 11/1/2023
1.0.82 992 10/26/2023
1.0.81 876 10/19/2023
1.0.80 103 10/19/2023
1.0.79 539 10/18/2023
1.0.78 119 10/18/2023
1.0.77 491 10/17/2023
1.0.76 105 10/17/2023
1.0.75 457 10/16/2023
1.0.74 112 10/16/2023
1.0.73 497 10/13/2023
1.0.72 254 10/12/2023
1.0.71 1,232 9/20/2023
1.0.70 424 9/19/2023
1.0.69 452 9/18/2023
1.0.68 104 9/18/2023
1.0.67 621 9/14/2023
1.0.66 1,066 8/31/2023
1.0.65 114 8/31/2023
1.0.64 548 8/30/2023
1.0.63 119 8/30/2023
1.0.62 123 8/30/2023
1.0.61 622 8/28/2023
1.0.60 510 8/25/2023
1.0.59 118 8/25/2023
1.0.58 349 8/24/2023
1.0.57 982 8/21/2023
1.0.56 554 8/18/2023
1.0.55 526 8/17/2023
1.0.54 121 8/17/2023
1.0.53 1,390 8/10/2023
1.0.52 424 8/9/2023
1.0.51 512 8/8/2023
1.0.50 482 8/7/2023
1.0.49 139 8/7/2023
1.0.48 1,748 7/13/2023
1.0.47 669 7/11/2023
1.0.46 563 7/10/2023
1.0.45 541 7/7/2023
1.0.44 134 7/7/2023
1.0.43 1,515 6/30/2023
1.0.42 799 6/29/2023
1.0.41 465 6/28/2023
1.0.40 1,154 6/26/2023
1.0.39 555 6/23/2023
1.0.38 804 6/21/2023
1.0.37 1,061 6/15/2023
1.0.36 353 6/14/2023
1.0.35 1,334 6/9/2023
1.0.34 662 6/8/2023
1.0.33 1,256 6/7/2023
1.0.32 132 6/7/2023
1.0.31 963 6/6/2023
1.0.30 913 6/5/2023
1.0.29 1,111 6/2/2023
1.0.28 122 6/2/2023
1.0.27 1,028 6/1/2023
1.0.26 492 5/31/2023
1.0.25 382 5/31/2023
1.0.24 122 5/31/2023
1.0.23 1,222 5/30/2023
1.0.22 1,270 5/26/2023
1.0.21 548 5/25/2023
1.0.20 118 5/25/2023
1.0.19 678 5/24/2023
1.0.18 120 5/24/2023
1.0.17 355 5/23/2023
1.0.13 1,186 5/22/2023
1.0.12 967 5/18/2023
1.0.11 473 5/17/2023
1.0.10 1,311 5/1/2023
1.0.9 843 4/25/2023
1.0.8 403 4/24/2023
1.0.7 870 4/21/2023
1.0.6 1,662 4/13/2023
1.0.5 497 4/12/2023
1.0.4 839 4/8/2023
1.0.3 166 4/8/2023
1.0.2 498 4/8/2023
1.0.1 156 4/8/2023