RKSoftware.Packages.Caching.System.Text.Json.Converter 3.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package RKSoftware.Packages.Caching.System.Text.Json.Converter --version 3.0.1
                    
NuGet\Install-Package RKSoftware.Packages.Caching.System.Text.Json.Converter -Version 3.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="RKSoftware.Packages.Caching.System.Text.Json.Converter" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RKSoftware.Packages.Caching.System.Text.Json.Converter" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="RKSoftware.Packages.Caching.System.Text.Json.Converter" />
                    
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 RKSoftware.Packages.Caching.System.Text.Json.Converter --version 3.0.1
                    
#r "nuget: RKSoftware.Packages.Caching.System.Text.Json.Converter, 3.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.
#:package RKSoftware.Packages.Caching.System.Text.Json.Converter@3.0.1
                    
#: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=RKSoftware.Packages.Caching.System.Text.Json.Converter&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=RKSoftware.Packages.Caching.System.Text.Json.Converter&version=3.0.1
                    
Install as a Cake Tool

RKSoftware.Packages.Caching.System.Text.Json.Converter

NuGet Downloads

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

  • NuGet — the core caching abstractions this package extends. Required.
  • NuGet — JSON string serialization with Newtonsoft.Json.
  • NuGet — 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 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. 
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.1.0 70 9/2/2026
3.0.1 75 9/1/2026
3.0.0 86 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