Soenneker.Utils.SingletonDictionary 2.1.373

Prefix Reserved
dotnet add package Soenneker.Utils.SingletonDictionary --version 2.1.373                
NuGet\Install-Package Soenneker.Utils.SingletonDictionary -Version 2.1.373                
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.373" />                
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.373                
#r "nuget: Soenneker.Utils.SingletonDictionary, 2.1.373"                
#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.373

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

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.373 1,170 7/25/2024
2.1.372 29 7/25/2024
2.1.371 380 7/25/2024
2.1.370 163 7/25/2024
2.1.369 191 7/25/2024
2.1.368 86 7/25/2024
2.1.367 215 7/24/2024
2.1.366 74 7/24/2024
2.1.365 107 7/24/2024
2.1.364 183 7/24/2024
2.1.363 4,538 7/20/2024
2.1.362 976 7/20/2024
2.1.361 3,493 7/14/2024
2.1.360 1,072 7/14/2024
2.1.359 63 7/14/2024
2.1.358 1,043 7/14/2024
2.1.357 3,058 7/10/2024
2.1.355 586 7/10/2024
2.1.354 822 7/10/2024
2.1.353 73 7/10/2024
2.1.352 1,472 7/10/2024
2.1.351 77 7/10/2024
2.1.350 62 7/10/2024
2.1.349 106 7/10/2024
2.1.348 62 7/10/2024
2.1.347 1,431 7/10/2024
2.1.346 77 7/10/2024
2.1.345 558 7/10/2024
2.1.344 67 7/10/2024
2.1.343 132 7/9/2024
2.1.342 65 7/9/2024
2.1.339 1,455 7/9/2024
2.1.338 344 7/9/2024
2.1.337 2,933 7/9/2024
2.1.336 735 7/9/2024
2.1.335 69 7/9/2024
2.1.334 1,787 7/9/2024
2.1.333 71 7/9/2024
2.1.332 801 7/9/2024
2.1.331 59 7/9/2024
2.1.330 1,765 7/9/2024
2.1.329 61 7/9/2024
2.1.328 758 7/9/2024
2.1.327 487 7/8/2024
2.1.326 660 7/8/2024
2.1.325 76 7/8/2024
2.1.324 71 7/8/2024
2.1.323 3,465 7/8/2024
2.1.322 1,105 7/8/2024
2.1.321 76 7/8/2024
2.1.320 1,589 7/7/2024
2.1.319 77 7/7/2024
2.1.318 79 7/7/2024
2.1.317 67 7/7/2024
2.1.316 787 7/7/2024
2.1.315 1,525 7/7/2024
2.1.314 1,282 7/7/2024
2.1.313 137 7/7/2024
2.1.312 2,387 7/5/2024
2.1.311 2,700 7/3/2024
2.1.310 2,118 7/3/2024
2.1.309 233 7/3/2024
2.1.308 2,702 7/2/2024
2.1.307 1,312 6/30/2024
2.1.306 1,570 6/28/2024
2.1.305 3,886 6/22/2024
2.1.304 3,536 6/15/2024
2.1.303 2,958 6/14/2024
2.1.302 4,315 6/1/2024
2.1.301 1,139 6/1/2024
2.1.300 408 6/1/2024
2.1.299 4,232 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,506 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,420 5/18/2024
2.1.274 1,364 5/18/2024
2.1.273 1,286 5/17/2024
2.1.272 73 5/17/2024
2.1.271 1,957 5/16/2024
2.1.270 303 5/15/2024
2.1.269 1,948 5/15/2024
2.1.268 3,151 5/12/2024
2.1.267 1,951 5/3/2024
2.1.266 782 4/30/2024
2.1.265 1,256 4/29/2024
2.1.264 1,393 4/29/2024
2.1.263 1,875 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 626 4/28/2024
2.1.258 69 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,505 4/12/2024
2.1.252 796 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 67 4/12/2024
2.1.247 708 4/12/2024
2.1.246 205 4/12/2024
2.1.245 1,176 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,456 3/29/2024
2.1.239 1,314 3/25/2024
2.1.238 202 3/25/2024
2.1.237 2,381 3/20/2024
2.1.236 1,525 3/19/2024
2.1.235 386 3/19/2024
2.1.234 1,652 3/18/2024
2.1.233 1,031 3/18/2024
2.1.232 1,009 3/15/2024
2.1.231 1,702 3/13/2024
2.1.230 807 3/13/2024
2.1.229 445 3/13/2024
2.1.228 554 3/13/2024
2.1.227 88 3/13/2024
2.1.226 386 3/13/2024
2.1.225 98 3/13/2024
2.1.224 88 3/13/2024
2.1.223 1,153 3/12/2024
2.1.222 2,008 3/11/2024
2.1.221 1,740 3/11/2024
2.1.220 1,174 3/10/2024
2.1.219 1,371 3/8/2024
2.1.218 765 3/8/2024
2.1.217 1,121 3/8/2024
2.1.216 1,509 3/6/2024
2.1.215 1,479 3/4/2024
2.1.214 1,016 3/4/2024
2.1.213 1,854 3/2/2024
2.1.212 860 3/2/2024
2.1.211 284 3/2/2024
2.1.210 241 3/2/2024
2.1.209 302 3/2/2024
2.1.208 2,550 2/29/2024
2.1.207 453 2/29/2024
2.1.206 225 2/29/2024
2.1.205 2,471 2/26/2024
2.1.204 1,097 2/25/2024
2.1.203 1,973 2/23/2024
2.1.202 1,439 2/22/2024
2.1.201 714 2/22/2024
2.1.200 292 2/21/2024
2.1.199 905 2/21/2024
2.1.198 208 2/21/2024
2.1.197 609 2/21/2024
2.1.196 98 2/21/2024
2.1.195 860 2/21/2024
2.1.194 300 2/21/2024
2.1.193 89 2/21/2024
2.1.192 89 2/21/2024
2.1.191 459 2/21/2024
2.1.190 71 2/21/2024
2.1.189 1,914 2/20/2024
2.1.188 563 2/20/2024
2.1.187 479 2/20/2024
2.1.186 490 2/20/2024
2.1.185 1,560 2/19/2024
2.1.184 1,378 2/17/2024
2.1.183 645 2/16/2024
2.1.182 662 2/16/2024
2.1.181 946 2/16/2024
2.1.180 75 2/16/2024
2.1.179 434 2/16/2024
2.1.178 69 2/16/2024
2.1.177 85 2/16/2024
2.1.176 398 2/16/2024
2.1.175 72 2/16/2024
2.1.174 2,486 2/13/2024
2.1.173 1,008 2/13/2024
2.1.172 819 2/13/2024
2.1.171 314 2/13/2024
2.1.170 456 2/13/2024
2.1.169 1,447 2/12/2024
2.1.168 396 2/11/2024
2.1.167 1,157 2/11/2024
2.1.166 652 2/11/2024
2.1.165 2,013 2/10/2024
2.1.164 415 2/9/2024
2.1.163 73 2/9/2024
2.1.162 1,139 2/9/2024
2.1.161 1,229 2/9/2024
2.1.160 263 2/8/2024
2.1.159 887 2/8/2024
2.1.158 648 2/8/2024
2.1.157 1,079 2/8/2024
2.1.156 76 2/8/2024
2.1.155 1,402 2/7/2024
2.1.154 315 2/7/2024
2.1.153 458 2/7/2024
2.1.152 932 2/7/2024
2.1.151 269 2/6/2024
2.1.150 85 2/6/2024
2.1.149 72 2/6/2024
2.1.148 2,091 2/5/2024
2.1.147 1,120 2/4/2024
2.1.146 1,525 2/2/2024
2.1.145 1,483 1/31/2024
2.1.144 1,631 1/29/2024
2.1.143 1,031 1/29/2024
2.1.142 255 1/29/2024
2.1.141 1,149 1/28/2024
2.1.140 341 1/28/2024
2.1.139 222 1/28/2024
2.1.138 420 1/28/2024
2.1.137 1,433 1/28/2024
2.1.136 687 1/28/2024
2.1.135 199 1/27/2024
2.1.134 719 1/27/2024
2.1.133 787 1/27/2024
2.1.132 884 1/27/2024
2.1.131 102 1/27/2024
2.1.130 555 1/27/2024
2.1.129 753 1/26/2024
2.1.128 142 1/26/2024
2.1.127 683 1/26/2024
2.1.126 802 1/26/2024
2.1.125 1,274 1/26/2024
2.1.124 619 1/25/2024
2.1.123 882 1/25/2024
2.1.122 346 1/25/2024
2.1.121 719 1/25/2024
2.1.120 401 1/25/2024
2.1.119 1,925 1/19/2024
2.1.118 1,728 1/15/2024
2.1.117 391 1/15/2024
2.1.116 900 1/15/2024
2.1.115 87 1/15/2024
2.1.114 434 1/15/2024
2.1.113 1,049 1/15/2024
2.1.112 2,006 1/14/2024
2.1.111 1,229 1/13/2024
2.1.110 1,473 1/12/2024
2.1.109 1,584 1/11/2024
2.1.108 2,094 1/7/2024
2.1.107 1,708 1/5/2024
2.1.106 337 1/5/2024
2.1.105 98 1/5/2024
2.1.104 92 1/5/2024
2.1.103 1,163 1/5/2024
2.1.102 105 1/5/2024
2.1.101 2,120 1/1/2024
2.1.100 1,726 12/28/2023
2.1.99 557 12/28/2023
2.1.98 355 12/28/2023
2.1.97 96 12/28/2023
2.1.96 94 12/28/2023
2.1.95 555 12/27/2023
2.1.94 86 12/27/2023
2.1.93 339 12/27/2023
2.1.92 81 12/27/2023
2.1.91 88 12/27/2023
2.1.90 1,582 12/25/2023
2.1.89 261 12/25/2023
2.1.88 480 12/25/2023
2.1.87 87 12/25/2023
2.1.86 444 12/25/2023
2.1.85 94 12/25/2023
2.1.84 383 12/25/2023
2.1.83 86 12/25/2023
2.1.82 1,115 12/24/2023
2.1.81 777 12/23/2023
2.1.80 545 12/23/2023
2.1.79 233 12/23/2023
2.1.78 405 12/23/2023
2.1.77 93 12/23/2023
2.1.76 83 12/23/2023
2.1.75 741 12/23/2023
2.1.74 82 12/23/2023
2.1.73 966 12/19/2023
2.1.72 154 12/19/2023
2.1.71 2,176 12/11/2023
2.1.70 511 12/10/2023
2.1.69 93 12/10/2023
2.1.68 371 12/10/2023
2.1.67 992 12/10/2023
2.1.66 247 12/9/2023
2.1.65 263 12/9/2023
2.1.64 207 12/9/2023
2.1.63 89 12/9/2023
2.1.62 196 12/9/2023
2.1.61 139 12/9/2023
2.1.60 87 12/9/2023
2.1.59 758 12/9/2023
2.1.58 90 12/9/2023
2.1.57 1,068 12/6/2023
2.1.56 255 12/6/2023
2.1.55 140 12/6/2023
2.1.54 202 12/6/2023
2.1.53 613 12/5/2023
2.1.52 256 12/5/2023
2.1.51 246 12/5/2023
2.1.50 250 12/5/2023
2.1.49 92 12/5/2023
2.1.48 254 12/5/2023
2.1.47 198 12/5/2023
2.1.46 94 12/4/2023
2.1.45 95 12/4/2023
2.1.44 252 12/4/2023
2.1.43 102 12/4/2023
2.1.42 593 12/4/2023
2.1.41 81 12/4/2023
2.1.40 803 11/27/2023
2.1.39 322 11/26/2023
2.1.38 130 11/26/2023
2.1.37 355 11/23/2023
2.1.36 443 11/23/2023
2.1.35 426 11/23/2023
2.1.34 93 11/23/2023
2.1.33 210 11/23/2023
2.1.32 84 11/23/2023
2.1.31 706 11/20/2023
2.1.30 606 11/20/2023
2.1.29 484 11/19/2023
2.1.28 147 11/19/2023
2.1.27 309 11/19/2023
2.1.26 290 11/19/2023
2.1.25 286 11/19/2023
2.1.24 87 11/19/2023
2.1.23 151 11/18/2023
2.1.22 625 11/18/2023
2.1.21 235 11/18/2023
2.1.20 327 11/18/2023
2.1.19 94 11/18/2023
2.1.18 180 11/18/2023
2.1.17 94 11/18/2023
2.1.16 354 11/17/2023
2.1.15 301 11/17/2023
2.1.14 92 11/17/2023
2.1.13 296 11/17/2023
2.1.12 188 11/17/2023
2.1.11 288 11/17/2023
2.1.10 86 11/17/2023
2.1.9 284 11/17/2023
2.1.8 90 11/17/2023
2.1.7 96 11/17/2023
2.1.6 220 11/17/2023
2.1.5 197 11/16/2023
2.0.101 1,258 11/15/2023
2.0.100 83 11/15/2023
2.0.99 89 11/15/2023
2.0.4 91 11/16/2023
2.0.3 93 11/16/2023
2.0.2 91 11/16/2023
2.0.1 89 11/16/2023
1.0.98 407 11/14/2023
1.0.97 532 11/13/2023
1.0.96 83 11/13/2023
1.0.95 427 11/10/2023
1.0.94 85 11/10/2023
1.0.93 566 11/9/2023
1.0.92 88 11/9/2023
1.0.91 658 11/7/2023
1.0.90 82 11/7/2023
1.0.89 349 11/6/2023
1.0.88 87 11/6/2023
1.0.87 442 11/3/2023
1.0.86 98 11/3/2023
1.0.85 573 11/2/2023
1.0.84 89 11/2/2023
1.0.83 438 11/1/2023
1.0.82 987 10/26/2023
1.0.81 871 10/19/2023
1.0.80 100 10/19/2023
1.0.79 532 10/18/2023
1.0.78 108 10/18/2023
1.0.77 486 10/17/2023
1.0.76 102 10/17/2023
1.0.75 452 10/16/2023
1.0.74 109 10/16/2023
1.0.73 492 10/13/2023
1.0.72 244 10/12/2023
1.0.71 1,226 9/20/2023
1.0.70 418 9/19/2023
1.0.69 446 9/18/2023
1.0.68 100 9/18/2023
1.0.67 615 9/14/2023
1.0.66 1,062 8/31/2023
1.0.65 112 8/31/2023
1.0.64 542 8/30/2023
1.0.63 115 8/30/2023
1.0.62 119 8/30/2023
1.0.61 618 8/28/2023
1.0.60 506 8/25/2023
1.0.59 110 8/25/2023
1.0.58 345 8/24/2023
1.0.57 978 8/21/2023
1.0.56 550 8/18/2023
1.0.55 520 8/17/2023
1.0.54 119 8/17/2023
1.0.53 1,386 8/10/2023
1.0.52 420 8/9/2023
1.0.51 508 8/8/2023
1.0.50 478 8/7/2023
1.0.49 136 8/7/2023
1.0.48 1,743 7/13/2023
1.0.47 663 7/11/2023
1.0.46 558 7/10/2023
1.0.45 533 7/7/2023
1.0.44 131 7/7/2023
1.0.43 1,508 6/30/2023
1.0.42 794 6/29/2023
1.0.41 459 6/28/2023
1.0.40 1,150 6/26/2023
1.0.39 549 6/23/2023
1.0.38 799 6/21/2023
1.0.37 1,056 6/15/2023
1.0.36 348 6/14/2023
1.0.35 1,329 6/9/2023
1.0.34 651 6/8/2023
1.0.33 1,249 6/7/2023
1.0.32 128 6/7/2023
1.0.31 957 6/6/2023
1.0.30 906 6/5/2023
1.0.29 1,106 6/2/2023
1.0.28 118 6/2/2023
1.0.27 1,023 6/1/2023
1.0.26 488 5/31/2023
1.0.25 376 5/31/2023
1.0.24 120 5/31/2023
1.0.23 1,217 5/30/2023
1.0.22 1,263 5/26/2023
1.0.21 544 5/25/2023
1.0.20 116 5/25/2023
1.0.19 673 5/24/2023
1.0.18 118 5/24/2023
1.0.17 346 5/23/2023
1.0.13 1,182 5/22/2023
1.0.12 963 5/18/2023
1.0.11 463 5/17/2023
1.0.10 1,307 5/1/2023
1.0.9 837 4/25/2023
1.0.8 397 4/24/2023
1.0.7 862 4/21/2023
1.0.6 1,655 4/13/2023
1.0.5 491 4/12/2023
1.0.4 833 4/8/2023
1.0.3 161 4/8/2023
1.0.2 486 4/8/2023
1.0.1 152 4/8/2023