public void fire(String key) {
Jedis jedis = null;
try {
jedis = LCacheManager.me.jedis();
String channel = (LCacheManager.PREFIX + name);
String msg = LCacheManager.me().id + ":" + key;
log.debugf("fire channel=%s msg=%s", channel, msg);
jedis.publish(channel, msg);
} finally {
Streams.safeClose(jedis);
}
}
这段代码的意义是啥啊 发布了以后 接收的代码是
public void onPMessage(String pattern, String channel, String message) {
log.debugf("channel=%s, msg=%s", channel, message);
if (message.startsWith(LCacheManager.me.id))
return;
String cacheName = channel.substring(LCacheManager.PREFIX.length());
LCache cache = LCacheManager.me.caches.get(cacheName);
if (cache != null && cache.list.size() > 1)
((Cache) cache.list.get(0)).remove(message.substring(LCacheManager.me.id.length() + 1));
}
这个为啥message.startsWith(LCacheManager.me.id) 直接return了。。