MethodCache.Serialization.MessagePack
1.0.0-rc.2
dotnet add package MethodCache.Serialization.MessagePack --version 1.0.0-rc.2
NuGet\Install-Package MethodCache.Serialization.MessagePack -Version 1.0.0-rc.2
<PackageReference Include="MethodCache.Serialization.MessagePack" Version="1.0.0-rc.2" />
<PackageVersion Include="MethodCache.Serialization.MessagePack" Version="1.0.0-rc.2" />
<PackageReference Include="MethodCache.Serialization.MessagePack" />
paket add MethodCache.Serialization.MessagePack --version 1.0.0-rc.2
#r "nuget: MethodCache.Serialization.MessagePack, 1.0.0-rc.2"
#:package MethodCache.Serialization.MessagePack@1.0.0-rc.2
#addin nuget:?package=MethodCache.Serialization.MessagePack&version=1.0.0-rc.2&prerelease
#tool nuget:?package=MethodCache.Serialization.MessagePack&version=1.0.0-rc.2&prerelease
MethodCache.Serialization.MessagePack
Requires .NET 10 and the .NET 10 SDK; use the same package version as MethodCache.
Install this package and MethodCache at the exact same version. Integration packages use Core internals;
do not override their exact Core dependency. Our package smoke tests promote NU1608 to a restore error.
Stores MethodCache's distributed cache values (Redis or SQL Server) as compact MessagePack instead of the default System.Text.Json: smaller entries and faster reads.
Install
dotnet add package MethodCache.Serialization.MessagePack
Register
builder.Services.AddMethodCache(mc => mc
.UseRedis("localhost:6379")
.UseMessagePack()); // MethodCache.Serialization.MessagePack
Call UseMessagePack() with UseRedis(...) or UseSqlServer(...), in any order; without either it does nothing and
logs a warning at startup. Entries written in the other format read as misses and are replaced, so switching needs
no flush.
When to use it
- Values are large or read often from the distributed cache. It has no effect on the in-memory cache, which stores your objects as they are.
- Types serialize without attributes (contractless resolver). The defaults use LZ4 compression, keep
DateTimevalues as they are, and read stored data withMessagePackSecurity.UntrustedData. - Like JSON, the contractless resolver doesn't restore private setters or a derived type returned as its base type.
With the default
VerifyRoundTrip = true, MethodCache reads every value back before sharing it, and keeps values that don't survive that in memory only, with one warning per method and type. - To change them, start from MethodCache's defaults:
UseMessagePack(o => o.WithCompression(MessagePackCompression.None))gets the defaults above and returns the options to use, so the rest stays as it was. KeepUntrustedDataand don't enable typeless payloads: the distributed cache must not choose which types get created (see Security). UseMessagePackchanges how values are stored, never cache keys. UseICacheKeyProviderfor custom argument parts.
The check cannot detect lost nested derived/private state that was absent from the first serialized
representation. Configure the serializer for your model. Increment method Version or
DistributedCacheOptions.SerializerVersion when changing the representation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- MessagePack (>= 3.1.11)
- MethodCache (= 1.0.0-rc.2)
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 |
|---|---|---|
| 1.0.0-rc.2 | 55 | 10/20/2026 |
| 1.0.0-rc.1 | 58 | 10/19/2026 |