Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Taking Azure Redis Cache for a ride – testing a simple Producer/Consumer program - Consumer
using System.Diagnostics;
using System.Threading;
using Microsoft.WindowsAzure.ServiceRuntime;
using StackExchange.Redis;namespace Consumer
{
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
Trace.TraceInformation("Consumer started");
Subscribe(ConnectionMultiplexer.Connect(""));
while (true)
{
Thread.Sleep(1000);
}
} public void Subscribe(ConnectionMultiplexer connection)
{
IDatabase cache = connection.GetDatabase();
ISubscriber subscriber = connection.GetSubscriber();
subscriber.Subscribe("ping", (channel, message) => { subscriber.Publish("pong", message); });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment