Soenneker.Utils.SingletonDictionary 1.0.11

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 1.0.11
NuGet\Install-Package Soenneker.Utils.SingletonDictionary -Version 1.0.11
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="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.SingletonDictionary --version 1.0.11
#r "nuget: Soenneker.Utils.SingletonDictionary, 1.0.11"
#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=1.0.11

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

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

Install-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 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 was computed.  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 (4)

Showing the top 4 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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.302 2,148 6/1/2024
2.1.301 1,131 6/1/2024
2.1.300 400 6/1/2024
2.1.299 4,225 5/31/2024
2.1.298 2,676 5/29/2024
2.1.297 2,163 5/28/2024
2.1.296 1,734 5/27/2024
2.1.295 3,497 5/26/2024
2.1.294 1,445 5/26/2024
2.1.293 320 5/26/2024
2.1.292 1,794 5/25/2024
2.1.291 969 5/25/2024
2.1.290 79 5/25/2024
2.1.289 78 5/25/2024
2.1.288 469 5/25/2024
2.1.287 79 5/25/2024
2.1.286 279 5/25/2024
2.1.285 82 5/25/2024
2.1.284 79 5/25/2024
2.1.283 5,363 5/23/2024
2.1.282 357 5/23/2024
2.1.281 177 5/22/2024
2.1.280 2,603 5/22/2024
2.1.279 82 5/22/2024
2.1.278 80 5/22/2024
2.1.277 81 5/22/2024
2.1.276 1,490 5/22/2024
2.1.275 2,415 5/18/2024
2.1.274 1,353 5/18/2024
2.1.273 1,281 5/17/2024
2.1.272 67 5/17/2024
2.1.271 1,954 5/16/2024
2.1.270 297 5/15/2024
2.1.269 1,944 5/15/2024
2.1.268 3,145 5/12/2024
2.1.267 1,768 5/3/2024
2.1.266 776 4/30/2024
2.1.265 1,252 4/29/2024
2.1.264 1,387 4/29/2024
2.1.263 1,869 4/28/2024
2.1.262 1,047 4/28/2024
2.1.261 779 4/28/2024
2.1.260 1,277 4/28/2024
2.1.259 618 4/28/2024
2.1.258 67 4/28/2024
2.1.257 3,036 4/27/2024
2.1.256 73 4/27/2024
2.1.255 3,194 4/19/2024
2.1.254 2,935 4/18/2024
2.1.253 2,490 4/12/2024
2.1.252 786 4/12/2024
2.1.251 510 4/12/2024
2.1.250 603 4/12/2024
2.1.249 119 4/12/2024
2.1.248 62 4/12/2024
2.1.247 703 4/12/2024
2.1.246 202 4/12/2024
2.1.245 1,172 4/11/2024
2.1.244 2,612 4/10/2024
2.1.243 813 4/9/2024
2.1.242 2,231 4/2/2024
2.1.241 629 4/1/2024
2.1.240 1,453 3/29/2024
2.1.239 1,311 3/25/2024
2.1.238 192 3/25/2024
2.1.237 2,371 3/20/2024
2.1.236 1,520 3/19/2024
2.1.235 383 3/19/2024
2.1.234 1,649 3/18/2024
2.1.233 1,028 3/18/2024
2.1.232 1,006 3/15/2024
2.1.231 1,695 3/13/2024
2.1.230 800 3/13/2024
2.1.229 440 3/13/2024
2.1.228 550 3/13/2024
2.1.227 83 3/13/2024
2.1.226 374 3/13/2024
2.1.225 91 3/13/2024
2.1.224 82 3/13/2024
2.1.223 1,142 3/12/2024
2.1.222 2,003 3/11/2024
2.1.221 1,728 3/11/2024
2.1.220 1,164 3/10/2024
2.1.219 1,365 3/8/2024
2.1.218 758 3/8/2024
2.1.217 1,114 3/8/2024
2.1.216 1,503 3/6/2024
2.1.215 1,471 3/4/2024
2.1.214 1,008 3/4/2024
2.1.213 1,842 3/2/2024
2.1.212 843 3/2/2024
2.1.211 277 3/2/2024
2.1.210 226 3/2/2024
2.1.209 293 3/2/2024
2.1.208 2,545 2/29/2024
2.1.207 450 2/29/2024
2.1.206 222 2/29/2024
2.1.205 2,462 2/26/2024
2.1.204 1,088 2/25/2024
2.1.203 1,968 2/23/2024
2.1.202 1,434 2/22/2024
2.1.201 709 2/22/2024
2.1.200 287 2/21/2024
2.1.199 900 2/21/2024
2.1.198 203 2/21/2024
2.1.197 604 2/21/2024
2.1.196 93 2/21/2024
2.1.195 855 2/21/2024
2.1.194 295 2/21/2024
2.1.193 84 2/21/2024
2.1.192 84 2/21/2024
2.1.191 450 2/21/2024
2.1.190 67 2/21/2024
2.1.189 1,909 2/20/2024
2.1.188 558 2/20/2024
2.1.187 474 2/20/2024
2.1.186 485 2/20/2024
2.1.185 1,555 2/19/2024
2.1.184 1,372 2/17/2024
2.1.183 641 2/16/2024
2.1.182 657 2/16/2024
2.1.181 941 2/16/2024
2.1.180 70 2/16/2024
2.1.179 431 2/16/2024
2.1.178 65 2/16/2024
2.1.177 80 2/16/2024
2.1.176 394 2/16/2024
2.1.175 67 2/16/2024
2.1.174 2,483 2/13/2024
2.1.173 1,004 2/13/2024
2.1.172 813 2/13/2024
2.1.171 310 2/13/2024
2.1.170 452 2/13/2024
2.1.169 1,443 2/12/2024
2.1.168 392 2/11/2024
2.1.167 1,153 2/11/2024
2.1.166 648 2/11/2024
2.1.165 2,009 2/10/2024
2.1.164 411 2/9/2024
2.1.163 69 2/9/2024
2.1.162 1,135 2/9/2024
2.1.161 1,223 2/9/2024
2.1.160 256 2/8/2024
2.1.159 882 2/8/2024
2.1.158 642 2/8/2024
2.1.157 1,075 2/8/2024
2.1.156 72 2/8/2024
2.1.155 1,398 2/7/2024
2.1.154 311 2/7/2024
2.1.153 452 2/7/2024
2.1.152 923 2/7/2024
2.1.151 265 2/6/2024
2.1.150 81 2/6/2024
2.1.149 66 2/6/2024
2.1.148 2,087 2/5/2024
2.1.147 1,116 2/4/2024
2.1.146 1,519 2/2/2024
2.1.145 1,479 1/31/2024
2.1.144 1,627 1/29/2024
2.1.143 1,027 1/29/2024
2.1.142 251 1/29/2024
2.1.141 1,145 1/28/2024
2.1.140 335 1/28/2024
2.1.139 210 1/28/2024
2.1.138 412 1/28/2024
2.1.137 1,429 1/28/2024
2.1.136 681 1/28/2024
2.1.135 195 1/27/2024
2.1.134 715 1/27/2024
2.1.133 783 1/27/2024
2.1.132 880 1/27/2024
2.1.131 96 1/27/2024
2.1.130 551 1/27/2024
2.1.129 749 1/26/2024
2.1.128 138 1/26/2024
2.1.127 679 1/26/2024
2.1.126 796 1/26/2024
2.1.125 1,265 1/26/2024
2.1.124 609 1/25/2024
2.1.123 876 1/25/2024
2.1.122 342 1/25/2024
2.1.121 715 1/25/2024
2.1.120 397 1/25/2024
2.1.119 1,921 1/19/2024
2.1.118 1,721 1/15/2024
2.1.117 387 1/15/2024
2.1.116 896 1/15/2024
2.1.115 83 1/15/2024
2.1.114 430 1/15/2024
2.1.113 1,045 1/15/2024
2.1.112 1,999 1/14/2024
2.1.111 1,223 1/13/2024
2.1.110 1,469 1/12/2024
2.1.109 1,582 1/11/2024
2.1.108 2,090 1/7/2024
2.1.107 1,701 1/5/2024
2.1.106 333 1/5/2024
2.1.105 94 1/5/2024
2.1.104 88 1/5/2024
2.1.103 1,157 1/5/2024
2.1.102 101 1/5/2024
2.1.101 2,116 1/1/2024
2.1.100 1,725 12/28/2023
2.1.99 556 12/28/2023
2.1.98 354 12/28/2023
2.1.97 95 12/28/2023
2.1.96 93 12/28/2023
2.1.95 554 12/27/2023
2.1.94 85 12/27/2023
2.1.93 338 12/27/2023
2.1.92 79 12/27/2023
2.1.91 86 12/27/2023
2.1.90 1,580 12/25/2023
2.1.89 259 12/25/2023
2.1.88 478 12/25/2023
2.1.87 85 12/25/2023
2.1.86 442 12/25/2023
2.1.85 92 12/25/2023
2.1.84 381 12/25/2023
2.1.83 84 12/25/2023
2.1.82 1,113 12/24/2023
2.1.81 775 12/23/2023
2.1.80 543 12/23/2023
2.1.79 231 12/23/2023
2.1.78 400 12/23/2023
2.1.77 91 12/23/2023
2.1.76 81 12/23/2023
2.1.75 739 12/23/2023
2.1.74 80 12/23/2023
2.1.73 964 12/19/2023
2.1.72 153 12/19/2023
2.1.71 2,175 12/11/2023
2.1.70 510 12/10/2023
2.1.69 92 12/10/2023
2.1.68 367 12/10/2023
2.1.67 991 12/10/2023
2.1.66 246 12/9/2023
2.1.65 262 12/9/2023
2.1.64 206 12/9/2023
2.1.63 88 12/9/2023
2.1.62 195 12/9/2023
2.1.61 138 12/9/2023
2.1.60 86 12/9/2023
2.1.59 757 12/9/2023
2.1.58 89 12/9/2023
2.1.57 1,067 12/6/2023
2.1.56 248 12/6/2023
2.1.55 139 12/6/2023
2.1.54 201 12/6/2023
2.1.53 612 12/5/2023
2.1.52 255 12/5/2023
2.1.51 239 12/5/2023
2.1.50 249 12/5/2023
2.1.49 91 12/5/2023
2.1.48 251 12/5/2023
2.1.47 195 12/5/2023
2.1.46 93 12/4/2023
2.1.45 94 12/4/2023
2.1.44 251 12/4/2023
2.1.43 101 12/4/2023
2.1.42 592 12/4/2023
2.1.41 80 12/4/2023
2.1.40 798 11/27/2023
2.1.39 321 11/26/2023
2.1.38 129 11/26/2023
2.1.37 354 11/23/2023
2.1.36 432 11/23/2023
2.1.35 425 11/23/2023
2.1.34 92 11/23/2023
2.1.33 209 11/23/2023
2.1.32 83 11/23/2023
2.1.31 705 11/20/2023
2.1.30 605 11/20/2023
2.1.29 483 11/19/2023
2.1.28 146 11/19/2023
2.1.27 308 11/19/2023
2.1.26 289 11/19/2023
2.1.25 285 11/19/2023
2.1.24 86 11/19/2023
2.1.23 150 11/18/2023
2.1.22 618 11/18/2023
2.1.21 234 11/18/2023
2.1.20 326 11/18/2023
2.1.19 93 11/18/2023
2.1.18 179 11/18/2023
2.1.17 93 11/18/2023
2.1.16 353 11/17/2023
2.1.15 300 11/17/2023
2.1.14 91 11/17/2023
2.1.13 295 11/17/2023
2.1.12 187 11/17/2023
2.1.11 287 11/17/2023
2.1.10 85 11/17/2023
2.1.9 283 11/17/2023
2.1.8 89 11/17/2023
2.1.7 95 11/17/2023
2.1.6 219 11/17/2023
2.1.5 196 11/16/2023
2.0.101 1,257 11/15/2023
2.0.100 82 11/15/2023
2.0.99 88 11/15/2023
2.0.4 90 11/16/2023
2.0.3 92 11/16/2023
2.0.2 90 11/16/2023
2.0.1 88 11/16/2023
1.0.98 406 11/14/2023
1.0.97 531 11/13/2023
1.0.96 82 11/13/2023
1.0.95 426 11/10/2023
1.0.94 84 11/10/2023
1.0.93 565 11/9/2023
1.0.92 87 11/9/2023
1.0.91 657 11/7/2023
1.0.90 81 11/7/2023
1.0.89 348 11/6/2023
1.0.88 86 11/6/2023
1.0.87 441 11/3/2023
1.0.86 97 11/3/2023
1.0.85 572 11/2/2023
1.0.84 88 11/2/2023
1.0.83 437 11/1/2023
1.0.82 980 10/26/2023
1.0.81 870 10/19/2023
1.0.80 99 10/19/2023
1.0.79 531 10/18/2023
1.0.78 107 10/18/2023
1.0.77 485 10/17/2023
1.0.76 101 10/17/2023
1.0.75 451 10/16/2023
1.0.74 102 10/16/2023
1.0.73 491 10/13/2023
1.0.72 243 10/12/2023
1.0.71 1,224 9/20/2023
1.0.70 417 9/19/2023
1.0.69 445 9/18/2023
1.0.68 99 9/18/2023
1.0.67 614 9/14/2023
1.0.66 1,061 8/31/2023
1.0.65 111 8/31/2023
1.0.64 541 8/30/2023
1.0.63 114 8/30/2023
1.0.62 118 8/30/2023
1.0.61 617 8/28/2023
1.0.60 505 8/25/2023
1.0.59 109 8/25/2023
1.0.58 344 8/24/2023
1.0.57 977 8/21/2023
1.0.56 543 8/18/2023
1.0.55 519 8/17/2023
1.0.54 118 8/17/2023
1.0.53 1,385 8/10/2023
1.0.52 417 8/9/2023
1.0.51 507 8/8/2023
1.0.50 477 8/7/2023
1.0.49 135 8/7/2023
1.0.48 1,742 7/13/2023
1.0.47 662 7/11/2023
1.0.46 557 7/10/2023
1.0.45 526 7/7/2023
1.0.44 130 7/7/2023
1.0.43 1,505 6/30/2023
1.0.42 793 6/29/2023
1.0.41 458 6/28/2023
1.0.40 1,149 6/26/2023
1.0.39 547 6/23/2023
1.0.38 796 6/21/2023
1.0.37 1,054 6/15/2023
1.0.36 346 6/14/2023
1.0.35 1,328 6/9/2023
1.0.34 650 6/8/2023
1.0.33 1,247 6/7/2023
1.0.32 127 6/7/2023
1.0.31 956 6/6/2023
1.0.30 903 6/5/2023
1.0.29 1,105 6/2/2023
1.0.28 117 6/2/2023
1.0.27 1,022 6/1/2023
1.0.26 486 5/31/2023
1.0.25 373 5/31/2023
1.0.24 119 5/31/2023
1.0.23 1,216 5/30/2023
1.0.22 1,262 5/26/2023
1.0.21 541 5/25/2023
1.0.20 115 5/25/2023
1.0.19 672 5/24/2023
1.0.18 117 5/24/2023
1.0.17 345 5/23/2023
1.0.13 1,181 5/22/2023
1.0.12 962 5/18/2023
1.0.11 462 5/17/2023
1.0.10 1,304 5/1/2023
1.0.9 836 4/25/2023
1.0.8 396 4/24/2023
1.0.7 859 4/21/2023
1.0.6 1,653 4/13/2023
1.0.5 490 4/12/2023
1.0.4 832 4/8/2023
1.0.3 154 4/8/2023
1.0.2 485 4/8/2023
1.0.1 151 4/8/2023