Soenneker.Utils.SingletonDictionary 2.1.309

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. 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.309
NuGet\Install-Package Soenneker.Utils.SingletonDictionary -Version 2.1.309
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.309" />
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.309
#r "nuget: Soenneker.Utils.SingletonDictionary, 2.1.309"
#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.309

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

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 (5)

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

Package Downloads
Soenneker.Utils.HttpClientCache The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Providing thread-safe singleton HttpClients

Soenneker.Cosmos.Database The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for storing Azure Cosmos databases

Soenneker.ServiceBus.Sender The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library that holds Azure Service senders

Soenneker.Google.Credentials The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

An async thread-safe singleton for Google OAuth credentials

Soenneker.Blazor.Utils.ModuleImport The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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.320 0 7/7/2024
2.1.319 0 7/7/2024
2.1.318 0 7/7/2024
2.1.317 0 7/7/2024
2.1.316 0 7/7/2024
2.1.315 0 7/7/2024
2.1.314 0 7/7/2024
2.1.313 0 7/7/2024
2.1.312 419 7/5/2024
2.1.311 1,546 7/3/2024
2.1.310 1,434 7/3/2024
2.1.309 210 7/3/2024
2.1.308 1,845 7/2/2024
2.1.307 1,124 6/30/2024
2.1.306 1,563 6/28/2024
2.1.305 3,879 6/22/2024
2.1.304 3,530 6/15/2024
2.1.303 2,954 6/14/2024
2.1.302 4,312 6/1/2024
2.1.301 1,136 6/1/2024
2.1.300 405 6/1/2024
2.1.299 4,229 5/31/2024
2.1.298 2,680 5/29/2024
2.1.297 2,166 5/28/2024
2.1.296 1,737 5/27/2024
2.1.295 3,503 5/26/2024
2.1.294 1,452 5/26/2024
2.1.293 323 5/26/2024
2.1.292 1,797 5/25/2024
2.1.291 976 5/25/2024
2.1.290 82 5/25/2024
2.1.289 81 5/25/2024
2.1.288 476 5/25/2024
2.1.287 82 5/25/2024
2.1.286 282 5/25/2024
2.1.285 85 5/25/2024
2.1.284 82 5/25/2024
2.1.283 5,366 5/23/2024
2.1.282 360 5/23/2024
2.1.281 180 5/22/2024
2.1.280 2,606 5/22/2024
2.1.279 85 5/22/2024
2.1.278 83 5/22/2024
2.1.277 84 5/22/2024
2.1.276 1,493 5/22/2024
2.1.275 2,417 5/18/2024
2.1.274 1,361 5/18/2024
2.1.273 1,283 5/17/2024
2.1.272 69 5/17/2024
2.1.271 1,956 5/16/2024
2.1.270 302 5/15/2024
2.1.269 1,946 5/15/2024
2.1.268 3,150 5/12/2024
2.1.267 1,779 5/3/2024
2.1.266 778 4/30/2024
2.1.265 1,253 4/29/2024
2.1.264 1,388 4/29/2024
2.1.263 1,870 4/28/2024
2.1.262 1,048 4/28/2024
2.1.261 780 4/28/2024
2.1.260 1,278 4/28/2024
2.1.259 625 4/28/2024
2.1.258 68 4/28/2024
2.1.257 3,043 4/27/2024
2.1.256 74 4/27/2024
2.1.255 3,195 4/19/2024
2.1.254 2,936 4/18/2024
2.1.253 2,495 4/12/2024
2.1.252 793 4/12/2024
2.1.251 511 4/12/2024
2.1.250 610 4/12/2024
2.1.249 126 4/12/2024
2.1.248 63 4/12/2024
2.1.247 704 4/12/2024
2.1.246 203 4/12/2024
2.1.245 1,173 4/11/2024
2.1.244 2,618 4/10/2024
2.1.243 814 4/9/2024
2.1.242 2,232 4/2/2024
2.1.241 630 4/1/2024
2.1.240 1,454 3/29/2024
2.1.239 1,312 3/25/2024
2.1.238 193 3/25/2024
2.1.237 2,377 3/20/2024
2.1.236 1,521 3/19/2024
2.1.235 384 3/19/2024
2.1.234 1,650 3/18/2024
2.1.233 1,029 3/18/2024
2.1.232 1,007 3/15/2024
2.1.231 1,698 3/13/2024
2.1.230 803 3/13/2024
2.1.229 443 3/13/2024
2.1.228 553 3/13/2024
2.1.227 86 3/13/2024
2.1.226 376 3/13/2024
2.1.225 94 3/13/2024
2.1.224 85 3/13/2024
2.1.223 1,145 3/12/2024
2.1.222 2,006 3/11/2024
2.1.221 1,737 3/11/2024
2.1.220 1,167 3/10/2024
2.1.219 1,368 3/8/2024
2.1.218 761 3/8/2024
2.1.217 1,115 3/8/2024
2.1.216 1,506 3/6/2024
2.1.215 1,474 3/4/2024
2.1.214 1,011 3/4/2024
2.1.213 1,845 3/2/2024
2.1.212 850 3/2/2024
2.1.211 280 3/2/2024
2.1.210 229 3/2/2024
2.1.209 296 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,093 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 454 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,377 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 260 2/8/2024
2.1.159 886 2/8/2024
2.1.158 646 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 70 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 217 1/28/2024
2.1.138 420 1/28/2024
2.1.137 1,433 1/28/2024
2.1.136 685 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,272 1/26/2024
2.1.124 613 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,003 1/14/2024
2.1.111 1,227 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 80 12/27/2023
2.1.91 87 12/27/2023
2.1.90 1,581 12/25/2023
2.1.89 260 12/25/2023
2.1.88 479 12/25/2023
2.1.87 86 12/25/2023
2.1.86 443 12/25/2023
2.1.85 93 12/25/2023
2.1.84 382 12/25/2023
2.1.83 85 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 249 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 799 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 440 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 981 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 544 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 418 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 527 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,055 6/15/2023
1.0.36 347 6/14/2023
1.0.35 1,329 6/9/2023
1.0.34 651 6/8/2023
1.0.33 1,248 6/7/2023
1.0.32 128 6/7/2023
1.0.31 957 6/6/2023
1.0.30 904 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 374 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 860 4/21/2023
1.0.6 1,654 4/13/2023
1.0.5 491 4/12/2023
1.0.4 833 4/8/2023
1.0.3 155 4/8/2023
1.0.2 486 4/8/2023
1.0.1 152 4/8/2023