Redis 队列操作

 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();
}
}
上一篇:Mac下配置/使用GitHub


下一篇:纯CSS绘制的三角形箭头图案【原创】