Respsody.Generators 0.0.2-alpha

This is a prerelease version of Respsody.Generators.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Respsody.Generators --version 0.0.2-alpha
                    
NuGet\Install-Package Respsody.Generators -Version 0.0.2-alpha
                    
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="Respsody.Generators" Version="0.0.2-alpha">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Respsody.Generators" Version="0.0.2-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Respsody.Generators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 Respsody.Generators --version 0.0.2-alpha
                    
#r "nuget: Respsody.Generators, 0.0.2-alpha"
                    
#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 Respsody.Generators@0.0.2-alpha
                    
#: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=Respsody.Generators&version=0.0.2-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Respsody.Generators&version=0.0.2-alpha&prerelease
                    
Install as a Cake Tool

Respsody

Respsody is an experimental, high-performance, asynchronous, general-purpose RESP3 client library written in C#. It's currently in an early stage of development and intended for experimentation and community feedback.

Quick start

using Respsody;
using Respsody.Resp;
using System.Net;

var clientFactory = new RespClientFactory();
var client = await clientFactory.Create(new IPEndPoint(IPAddress.Loopback, 6379));

await client.Set(Key.Utf8("my_byte_array_key"), Value.ByteArray([0, 3, 0, 3, 6, 6]));
await client.Set(Key.Utf8("my_gob_key"), Value.Utf8("goblins are better than trolls."));

//**always** dispose non-void responses and do it exactly once
using var getResponse = await client.Get(Key.Utf8("my_byte_array_key"));

//for aggregate responses(arrays, maps, sets, pushes) dispose only root response
using var mgetResponse = await client.Mget([Key.Utf8("my_byte_array_key"), Key.Utf8("my_string_key")]);

var arr = mgetResponse[0].ToRespString().GetSpan().ToArray();
var str = mgetResponse[1].ToRespString().ToString(Encoding.UTF8);

//generate commands
[RespCommand("GET key", ResponseType.String)]
[RespCommand("SET key value", ResponseType.Void)]
[RespCommand("MGET key [key ...]", ResponseType.Array)]
[RespCommand("MSET key value [key value ...]", ResponseType.Void)]
[RespCommand("COMMAND DOCS [command-name:string [command-name:string ...]]", ResponseType.Map)]
public static class Commands;

Cluster usage:

using Respsody.Cluster;

var clusterRouter = new ClusterRouter(
    new ClusterRouterOptions
    {
        SeedEndpoints = ["some_cluster_host1:6379", "some_cluster_host2:6379"],
        ClientOptions = new RespClientOptions()
    });

await clusterRouter.Initialize();

// execute command on primary node that is responsible for key
using var v1 = await clusterRouter.RouteTo(RolePreference.Primary).Get(Key.Utf8("some_key_1"));

// pick random node and execute COMMAND DOCS on it
using var docs = await clusterRouter.PickRandom().Command(COMMAND.DOCS);

//group objects by node and execute commands on it
(Key Key, Value Value)[] objects = [(Key.Utf8("k_1"), Value.Utf8("v_1")), /* ... */ (Key.Utf8("k_n"), Value.Utf8("v_n"))];
foreach (var (node, nodeObjects)in clusterRouter.RouteTo(RolePreference.Primary).GroupBy(objects, o => o.Key))
    await node.Mset(nodeObjects);

Disclaimer

This project is an independent work and is not endorsed, supported, or certified by Redis.

License

This project is licensed under the MIT License.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Respsody.Generators:

Package Downloads
Respsody

General purpose RESP client

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.4-alpha 76 8/22/2025
0.0.3-alpha 145 8/8/2025
0.0.2-alpha 174 8/4/2025
0.0.1-alpha 96 8/3/2025