class Program
{
//版本2:使用Redis的客户端管理器(对象池)
public static IRedisClientsManager redisClientManager = new PooledRedisClientManager(new string[]
{
//如果是Redis集群则配置多个{IP地址:端口号}即可
//例如: "10.0.0.1:6379","10.0.0.2:6379","10.0.0.3:6379"
"127.0.0.1:6379"
});
//从池中获取Redis客户端实例
public static IRedisClient redisClient = redisClientManager.GetClient();
static void Main(string[] args)
{
// redisClient.Password = "123";
redisClient.EnqueueItemOnList("test", "Hello World!");
redisClient.EnqueueItemOnList("test", "Hello World2!");
Timer t = new Timer((o) =>
{
var value = redisClient.DequeueItemFromList("test");
if (string.IsNullOrWhiteSpace(value))
{
Console.WriteLine("队列中数据不存在!");
}
else
{
Console.WriteLine(value);
}
}, null, 5000, 5000);
Console.Read();
}
}