DotNetXtensions.DCache 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotNetXtensions.DCache --version 1.0.1
NuGet\Install-Package DotNetXtensions.DCache -Version 1.0.1
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="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetXtensions.DCache --version 1.0.1
#r "nuget: DotNetXtensions.DCache, 1.0.1"
#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 DotNetXtensions.DCache as a Cake Addin
#addin nuget:?package=DotNetXtensions.DCache&version=1.0.1

// Install DotNetXtensions.DCache as a Cake Tool
#tool nuget:?package=DotNetXtensions.DCache&version=1.0.1

DotNetXtensions.DCache

DCache is intended to be a simple typed version of IDistributedCache, useful when getting or putting a single type from the cache of a given type T. Thus behind the scenes this type handles serialization / deserialization of the raw strings and bytes to and from the cache, allowing the caller to treat this almost as as a simple in-memory dictionary. A second major purpose of this type is that it allows in-memory caching to be employed (for a specified time), by means of an internal DotNetXtensions.CacheDictionary{TKey, TValue} instance (thus the dependency on nuget pkg DotNetXtensions.Common). This can be powerful in less change-sensitive scenarios. In those cases it can remove the extra latency of a cache call entirely, when within a certain window and when this (server etc) instance had let's say just accessed the given item and it is still in memory.

CONSIDERATIONS

This type makes a number of basic assumptions, that makes this type useful only when the following considerations are acceptable:

  1. This encapsulates a single type. Nothing stops using multiple instances, but compared to the full IDistributedCache, this type is limited to a single keyed type access of items from the backing cache. E.g. to access a CustomerInfo type stored in the cache to be saved / retrieved using a singular keyed prefix, namely CacheKeyPrefix.

  2. Serialization / deserialization of the type T is performed right now by System.Text.Json.JsonSerializer (.NET's new json serializer). While a binary serializer may be nice, the simplicity of this right now wins out. While you can set a custom System.Text.Json.JsonSerializerOptions instance, if this json serializer doesn't suffice for serializing the type T, then this won't work.

  3. The key type TId must be able to serialize to a string for the cache key by means of calling ToString on it. This limitation could be solved later, but is here for the moment.

  4. This type is strongly bound (on purpose) to IDistributedCache, and thus also to the Microsoft.Extensions.Caching.Distributed namespace, and to the closely related DistributedCacheEntryOptions type. It also takes a dependency on the internally used CacheDictionary{TKey, TValue} type from

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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

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
2.0.0 594 3/9/2022
1.0.1 441 12/14/2021
1.0.0 400 12/14/2021