Skip to content

Instantly share code, notes, and snippets.

@vainolo
Created October 29, 2018 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vainolo/b41dec5ebe0f04e75ca31de255533d79 to your computer and use it in GitHub Desktop.
Save vainolo/b41dec5ebe0f04e75ca31de255533d79 to your computer and use it in GitHub Desktop.
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