Redb.SystemTextJson 0.0.3

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

Redb.NET

redb (An embedded key-value database for Rust) bindings for .NET and Unity.

NuGet Releases license

English | 日本語

Overview

Redb.NET is a high-performance C# binding for redb, an embedded database implemented in Rust.

While SQLite is well-known as an embedded database and RocksDB as a key-value database, redb stands out as an excellent choice for its simplicity, high performance, and support for concurrency.

Redb.NET provides a high-level binding for redb and offers an easy-to-use API for C#. The binding layer is carefully tuned for performance, ensuring no overhead.

Installation

NuGet packages

Redb.NET requires .NET Standard 2.1 or later. The package is available on NuGet.

.NET CLI

dotnet add package Redb

Package Manager

Install-Package Redb

Unity

WIP

Quick Start

using Redb;

using var db = RedbDatabase.Create("test.redb", RedbDatabaseOptions.Default);

using (var tx = db.BeginWrite())
{
    using (var table = tx.OpenTable<string, int>("my_table"))
    {
        table.Insert("foo", 12);
        table.Insert("bar", 30);
    }

    writetx.Commit();
}

using (var tx = db.BeginRead())
{
    using (var table = tx.OpenTable<string, int>("my_table"))
    {
        var foo = table.Get("foo");
        Console.WriteLine($"foo: {foo}");

        if (table.TryGet("bar", out var bar))
        {
            Console.WriteLine($"bar: {bar}");
        }
    }
}

Table API

You can open Table/ReadOnlyTable using OpenTable(). Both generic and non-generic types are available.

// generic table
using var table1 = tx.OpenTable<string, int>("my_table");

// non-generic table
using var table2 = tx.OpenTable("my_table");

In Table<TKey, TValue>/ReadOnlyTable<TKey, TValue>, the keys and values are strongly typed during read and write operations.

table1.Insert("foo", 1);
int value = readOnlyTable1.Get("foo");

Serialization is automatically handled by the IRedbEncoding set in RedbDatabase. By default, primitive types and some other types are supported, but you can connect a custom serializer to support any type. See the C# Serialization section for details.

In Table/ReadOnlyTable, you can directly read and write untyped binary data.

table2.Insert("foo"u8, "bar"u8);
RedbBlob blob = readOnlyTable2.Get("foo"u8);

RedbBlob is a struct that wraps a pointer on the Rust side. It allows you to read values without overhead, but you must dispose of it using Dispose().

var span = blob.AsSpan();
span.CopyTo(buffer);
blob.Dispose();

Compaction

You can perform compaction by calling Compact().

db.Compact();

By default, redb database files are larger than 1MB, but compaction can reduce them to around a few dozen KB.

C# Serialization

By default, binary (ReadOnlySpan<byte>), primitive types, Guid, DateTime, and TimeSpan can be used as keys or values. By connecting a serializer to the database, you can use any object as a key or value.

Currently, System.Text.Json is supported, and support for MessagePack for C# and MemoryPack is planned.

using Redb;
using Redb.SystemTextJson;

using var db = RedbDatabase.Create("test.redb", RedbDatabaseOptions.Default)
    .WithJsonSerializer();

using (var tx = db.BeginWrite())
{
    using (var table = tx.OpenTable<string, Person>("persons"))
    {
        table.Insert("alice", new Person("Alice", 18));
        table.Insert("bob", new Person("Bob", 30));
    }

    tx.Commit();
}

using (var tx = db.BeginRead())
{
    using (var table = tx.OpenTable<string, Person>("persons"))
    {
        var alice = table.Get("alice");
        var bob = table.Get("bob");
        Console.WriteLine(alice);
        Console.WriteLine(bob);
    }
}

record Person(string Name, int Age);

Supported Features

Redb.NET is currently in preview, and some features like Savepoint and MultimapTable are not yet implemented in the C# API. These are planned to be supported in the stable release.

License

This library is provided under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.0.4 123 1/18/2026
0.0.3 111 1/14/2026
0.0.2 109 1/14/2026