什么是Redis' redis.publish()'方法呢?

时间:2015-01-26 11:11:43

标签: java redis lettuce

redis.publish(); 方法在以下模块中执行了哪些操作。

redis.publish("WordCountTopology", exclamatedWord.toString() + "|" + Long.toString(count));

public void execute(Tuple tuple)
    {
      String word = tuple.getString(0);

      StringBuilder exclamatedWord = new StringBuilder();
      exclamatedWord.append(word).append("!!!");

      _collector.emit(tuple, new Values(exclamatedWord.toString()));

      long count = 30;
      redis.publish("WordCountTopology", exclamatedWord.toString() + "|" + Long.toString(count));
    }

1 个答案:

答案 0 :(得分:6)

它将字符串(ExclamatedWord +“| 30”)发布到名为WordCountTopology的Redis频道 - 该频道的订阅者将在redis.publish执行后收到该消息。

有关Redis'Pub / Sub的详细信息,请参阅:http://redis.io/topics/pubsub