Skip to content

Latest commit

 

History

History
60 lines (50 loc) · 2.56 KB

README.md

File metadata and controls

60 lines (50 loc) · 2.56 KB

RedisLite

Redis Lite is a small, simple redis client for .NET (Standard). It implements the often used redis commands, and then some.

Build Status Coverage Status Nuget License: MIT pull requests: welcome

Usage

AsyncRedisClient

Create an AsyncRedisClient and connect it to the redis server of your choosing:

using(var client = new AsyncRedisClient())
{
    var connectionSettings = new ConnectionSettings(address: "127.0.0.1", port: 6379);
    await client.Connect(connectionSettings);

Then you can start commanding:

    await client.Set("MyKey", "MyValue");
    var result = await client.Get("MyKey");
    await client.Del("MyKey");
    ...
}

AsyncRedisSubscriptionClient

Subscribing to redis channels is done through a special client, the AsyncRedisSubscriptionClient:

// Create a client and connect to a server:
var subscriber = new AsyncRedisSubscriptionClient();
var connectionSettings = new ConnectionSettings(address: "127.0.0.1", port: 6379);
await subscriber.Connect(connectionSettings);

// Register callcback for subscription:
subscriber.OnMessageReceived += (channel, message) =>
{
    // Do something when a message arrives.
};

// Subscribe to the channel you wish to recieve messages from:
subscriber.Subscribe("MyChannel");

Sending messages to a channel is done through the regular AsyncRedisClient:

// Create a client and connect to a server:
var publisher = new AsyncRedisClient();
var connectionSettings = new ConnectionSettings(address: "127.0.0.1", port: 6379);
await publisher.Connect(connectionSettings);

// Publish a message to a given channel:
await publisher.Publish("MyChannel", "My interesting message");

Included redis commands

The list of included redis commands can be seen here: RedisCommands.cs