您的位置:首页 > 数据库 > Redis

C#——Redis队列模式

2017-08-22 14:05 260 查看
1.插入队列(生产者)

private static RedisClient client = new RedisClient("127.0.0.1", 6379, null);
client.EnqueueItemOnList(listId, valuestr);


2.读取队列(消费者)

private static RedisClient client = new RedisClient("127.0.0.1", 6379, null);
////阻塞模式读取
string value = client.BlockingDequeueItemFromList(listId,new TimeSpan(1));
///非阻塞模式读取
string value = client.DequeueItemFromList(listId);


注.可以开启多个生产者往队列里插入数据,同时可以开启多个消费之从队列里读取数据。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: