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" />
                    
Directory.Packages.props
<PackageReference Include="DotNetXtensions.DCache" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=DotNetXtensions.DCache&version=3.0.4
                    
Install as a Cake Tool

DotNetXtensions.DCache

NuGet

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

📖 Full Documentation

// 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 ConcurrentDictionary for 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 IDisposable cached values

DCache

📖 Full Documentation

// Combines L1 (memory) + L2 (distributed) caching
DCache<User, string> cache = new(distributedCache);
await cache.SetAsync("user123", user);

User retrieved = await cache.GetAsync("user123");

Features

  1. Simplicity: With little effort or boilerplate, an IDistributedCache looks and acts like a simple in-memory typed dictionary
  2. Dual-Layer Caching: Combines fast (optional) in-memory caching (L1) with distributed caching (L2) for optimal performance
  3. Automatic Serialization: Handles JSON serialization/deserialization transparently using System.Text.Json
  4. 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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.4 111 2/27/2026
2.0.0 1,528 3/9/2022 2.0.0 is deprecated because it is no longer maintained.