RKSoftware.Packages.Caching.System.Text.Json.Converter
3.1.0
dotnet add package RKSoftware.Packages.Caching.System.Text.Json.Converter --version 3.1.0
NuGet\Install-Package RKSoftware.Packages.Caching.System.Text.Json.Converter -Version 3.1.0
<PackageReference Include="RKSoftware.Packages.Caching.System.Text.Json.Converter" Version="3.1.0" />
<PackageVersion Include="RKSoftware.Packages.Caching.System.Text.Json.Converter" Version="3.1.0" />
<PackageReference Include="RKSoftware.Packages.Caching.System.Text.Json.Converter" />
paket add RKSoftware.Packages.Caching.System.Text.Json.Converter --version 3.1.0
#r "nuget: RKSoftware.Packages.Caching.System.Text.Json.Converter, 3.1.0"
#:package RKSoftware.Packages.Caching.System.Text.Json.Converter@3.1.0
#addin nuget:?package=RKSoftware.Packages.Caching.System.Text.Json.Converter&version=3.1.0
#tool nuget:?package=RKSoftware.Packages.Caching.System.Text.Json.Converter&version=3.1.0
RKSoftware.Packages.Caching.System.Text.Json.Converter
System.Text.Json serialization for
RKSoftware.Packages.Caching. It
contains an IObjectToTextConverter implementation together with the registration extension that
plugs it into the cache service, so cached objects are stored in Redis as JSON strings.
The core caching package defines how values are cached but not how they are serialized — this package supplies the missing half. Register exactly one converter package in an application.
Installation
dotnet add package RKSoftware.Packages.Caching
dotnet add package RKSoftware.Packages.Caching.System.Text.Json.Converter
Getting started
Chain the converter registration onto the cache registration:
using RKSoftware.Packages.Caching.Infrastructure;
using RKSoftware.Packages.Caching.System.Text.Json.Converter;
builder.Services
.UseRKSoftwareCache(
builder.Configuration.GetSection(nameof(RedisCacheSettings)),
scopedKeyPrefix: "MyApp")
.UseSystemTextJsonTextConverter();
Nothing else is required — ICacheService now serializes with System.Text.Json:
using RKSoftware.Packages.Caching.Contract;
public sealed class ProductService(ICacheService cache, IProductRepository repository)
{
public Task<Product?> GetAsync(int id) =>
cache.GetOrSetCachedObjectAsync(
$"product.{id}",
() => repository.LoadAsync(id),
storageDuration: 600);
}
What it registers
UseSystemTextJsonTextConverter() (namespace
RKSoftware.Packages.Caching.System.Text.Json.Converter) adds two scoped services:
| Contract | Implementation |
|---|---|
IObjectToTextConverter |
SystemTextJsonTextConverter |
ICacheRepository |
StringCacheRepository |
API overview
SystemTextJsonTextConverter implements IObjectToTextConverter:
| Member | Behaviour |
|---|---|
string ToString<T>(T obj) |
JsonSerializer.Serialize of the value. |
T FromString<T>(string data) |
JsonSerializer.Deserialize. Throws InvalidOperationException when deserialization yields null. |
Both members are constrained to where T : class, matching ICacheService. Serialization uses the
System.Text.Json defaults, so annotate your models with System.Text.Json.Serialization
attributes ([JsonPropertyName], [JsonIgnore], [JsonConverter]) to influence the output.
Choosing a converter
- Use this package for new code:
System.Text.Jsonis built into the framework and adds no extra dependency. - Use
RKSoftware.Packages.Caching.Newtonsoft.Json.Converter
when your models already rely on
Newtonsoft.Jsonattributes or custom converters. - Use
RKSoftware.Packages.Caching.System.Text.Json.StreamConverter
for large payloads: it serializes straight to UTF-8 bytes and deserializes from a stream, avoiding
the intermediate
stringthis package produces.
Related packages
— the core caching abstractions this package extends. Required.
— JSON string serialization with
Newtonsoft.Json.— UTF-8 byte and stream serialization with
System.Text.Json.
Source, issues and full documentation: github.com/rk-software-systems/rk-dn-redis-cache-provider
License
Released into the public domain under The Unlicense.
| 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
- RKSoftware.Packages.Caching (>= 3.1.0)
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.1.0 | 70 | 9/2/2026 |
| 3.0.1 | 74 | 9/1/2026 |
| 3.0.0 | 85 | 8/30/2026 |
| 2.0.4 | 456 | 6/9/2023 |
| 2.0.3 | 452 | 2/8/2023 |
| 2.0.2 | 431 | 2/8/2023 |
| 2.0.1 | 451 | 2/7/2023 |
| 2.0.0 | 466 | 2/5/2023 |
| 1.0.6 | 6,529 | 9/24/2021 |
| 1.0.5 | 613 | 9/17/2021 |
| 1.0.4 | 1,767 | 4/17/2021 |
| 1.0.3 | 855 | 3/22/2021 |
| 1.0.2.1 | 583 | 3/22/2021 |
| 1.0.2 | 584 | 3/22/2021 |
| 1.0.1 | 734 | 9/24/2020 |
| 1.0.0 | 696 | 9/8/2020 |