DotNetXtensions.DCache
3.0.4
dotnet add package DotNetXtensions.DCache --version 3.0.4
NuGet\Install-Package DotNetXtensions.DCache -Version 3.0.4
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="DotNetXtensions.DCache" Version="3.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetXtensions.DCache" Version="3.0.4" />
<PackageReference Include="DotNetXtensions.DCache" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetXtensions.DCache --version 3.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DotNetXtensions.DCache, 3.0.4"
#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.
#:package DotNetXtensions.DCache@3.0.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetXtensions.DCache&version=3.0.4
#tool nuget:?package=DotNetXtensions.DCache&version=3.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotNetXtensions.DCache
High-performance caching types for .NET 8+
- CacheDictionary: Thread-safe in-memory cache dictionary with automatic time-based expiration
- DCache: Allows an IDistributedCache to look and act like a simple in-memory typed dictionary, with dual-layer caching
Installation
dotnet add package DotNetXtensions.DCache
CacheDictionary
// Items auto-expire after 5 minutes
CacheDictionary<string, User> cache = new(TimeSpan.FromMinutes(5));
cache["user123"] = new User { Name = "Alice" };
if (cache.TryGetValue("user123", out User user))
WriteLine(user.Name);
Features
- Time-Based Expiration: Items automatically expire after a set duration
- Thread-Safe: Built on
ConcurrentDictionaryfor safe concurrent access - High Performance: Minimal overhead on normal Get/Set operations
- Passive Purging: Expired items are removed intelligently without requiring external timers
- Guaranteed Fresh Data: Expired items are never returned, even if still present internally
- Automatic Disposal: Optional automatic disposal of
IDisposablecached values
DCache
// Combines L1 (memory) + L2 (distributed) caching
DCache<User, string> cache = new(distributedCache);
await cache.SetAsync("user123", user);
User retrieved = await cache.GetAsync("user123");
Features
- Simplicity: With little effort or boilerplate, an
IDistributedCachelooks and acts like a simple in-memory typed dictionary - Dual-Layer Caching: Combines fast (optional) in-memory caching (L1) with distributed caching (L2) for optimal performance
- Automatic Serialization: Handles JSON serialization/deserialization transparently using
System.Text.Json - Simplified API: Reduces boilerplate code for common caching patterns with typed keys and values
When to Use Which?
| Use CacheDictionary when... | Use DCache when... |
|---|---|
| Single-server scenarios | Multi-server/distributed systems |
| You need time-based expiration | You're already using IDistributedCache |
| Synchronous access is preferred | You need Redis, SQL Server, or other distributed caches |
| Memory-only caching is sufficient | You want L1 + L2 caching optimization |
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.