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 client = new RedisClient("127.0.0.1", );
for (int i = ; i < ; i++)
{
//将异常信息入队
redisClient.EnqueueItemOnList("ExceptionLog", i.ToString());
// var query = client.Increment("zizeng", 3);
Console.WriteLine("进入队列的值:" + i.ToString());
}
while (true)
{
if (redisClient.GetListCount("ExceptionLog") > )
{
//从队列中出队,获取异常对象
string errorMsg = redisClient.DequeueItemFromList("ExceptionLog");
Console.WriteLine("取出的队列:" + errorMsg);
}
}
Console.ReadKey();
}
}