All Projects → neuecc → RespClient

neuecc / RespClient

Licence: MIT license
RespClient is a minimal RESP(REdis Serialization Protocol) client for C# and PowerShell.

Programming Languages

C#
18002 projects
powershell
5483 projects
Batchfile
5799 projects

Build status

RespClient

RespClient is a minimal RESP(REdis Serialization Protocol) client for C# and PowerShell.

What's the diferrence between other .NET Redis Client

.NET has several Redis Client, BookSleeve (and it's wrapper CloudStructures), ServiceStack.Redis, etc. There are heavy for command line usage. RespClient is focusing on simple command usage like Redis-Cli. It's higher match for PowerShell.

Install

Binary is registered at NuGet, RespClient.

# Standalone PowerShell Cmdlet and .NET Client, requires System.Management.Automation
PM> Install-Package RespClient

PowerShell Cmdlet

# Module is provided by dll 
Import-Module RespClient.dll

# Connect to RedisServer. Connection is effective during powershell session.
# other parameter, -Host, -Port, -Timeout
Connect-RedisServer 127.0.0.1

# Send Command to RedisServer. Return value was decoded UTF8 string.
Send-RedisCommand "set test abcde"

# Support pipeline mode.
Begin-RedisPipeline
Send-RedisCommand "set test fghijk"
Send-RedisCommand "incr testb"
Send-RedisCommand "incr testc"
Send-RedisCommand "get test"
Execute-RedisPipeline

# Cleanup Connection explicitly 
Disconnect-RedisServer

RespClient(.NET)

If use raw RespClient, you can send binary value and choose other decoder(besides Encoding.UTF8).

using (var client = new Redis.Protocol.RespClient())
{
    // string command
    client.SendCommand("set a 100", Encoding.UTF8.GetString);

    // binary safe command
    client.SendCommand("set", new[] { Encoding.UTF8.GetBytes("test"), Encoding.UTF8.GetBytes("abcde") }, Encoding.UTF8.GetString);

    // use pipeline
    var results = client.UsePipeline()
        .QueueCommand("incr a")
        .QueueCommand("incrby b 10")
        .QueueCommand("get a", Encoding.UTF8.GetString)
        .Execute();
} // disconnect on dispose
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].