I am trying to put together a super simple ordering example based on BookSleeve.
Here is what I still have in line for the consumer:
using System;
using System.Text;
using BookSleeve;
static class Program
{
static void Main()
{
using (var redis = new RedisConnection("127.0.0.1"))
{
redis.Open();
while (true)
{
var t = redis.Lists.BlockingRemoveFirst(0, new[] { "test" }, 0);
t.Wait();
var val = Encoding.UTF8.GetString(t.Result.Item2);
Console.WriteLine("Got: {0}", val);
}
}
}
}
I run the following in LINQPad as a manufacturer:
using(var redis = new RedisConnection("localhost"))
{
redis.Open();
foreach(var i in Enumerable.Range(0, 10))
{
redis.Lists.AddFirst(0, "test", "foo" + i)
.Wait();
}
Thread.Sleep(500);
Console.WriteLine("queue length: " + redis.Lists.GetLength(0, "test").Result);
}
I get some weird results:
1st run:
Got: foo2
Got: foo5
Got: foo7
Got: foo9
2nd run:
Got: foo1
Got: foo4
Got: foo7
3rd run:
Got: foo0
Got: foo3
Got: foo6
Got: foo8
In addition, after each start, LINQPad displays: queue length: 0and works LLEN testusing the actual client redis returns (integer) 0.
I can’t help but feel that something is missing here, most likely due to asynchronous material, but I just don’t see it.
My version of redis is 2.8.3, the version of BookSleeve is 1.3.41.
: BookSleeve , redis?