public static string BlockingPopItemFromList(string listId, TimeSpan?timeOut) { using (RedisClient client = GetClient()) { return(client.BlockingPopItemFromList(listId, timeOut)); } }
/// <summary> /// 同步阻塞获取消息(推) /// </summary> /// <param name="queueName">队列名称</param> /// <param name="timeout">阻塞超时时间</param> /// <returns>消息</returns> public string GetMessageBlock(string queueName, TimeSpan?timeout = null) { // 阻塞等待获取消息 string message = _redisClient.BlockingPopItemFromList(queueName, timeout); return(message); }
public string BlockingPopItemFromList(string listId, TimeSpan?timeOut) { return(redisClient.BlockingPopItemFromList(listId, timeOut)); }
private void button17_Click(object sender, EventArgs e) { //移除列表最右边的一个元素,若不存在,则阻塞等待1秒,若1秒时间之后仍然不存在,返回空。 //语义:栈概念上的弹出含义 textBox1.Text += "\r\n " + client.BlockingPopItemFromList("list:name",TimeSpan.FromSeconds(1)); }