2016-08-04 46 views
0

我在Spring中编写一个Web应用程序,并且使用Spring Data Redis和Jedis。 Web应用程序会谈到的Redis集群有很多的命令集” 我想将命令发送到Redis的集群中的一个管道。当我尝试,我得到了一个例外:不支持JedisCluster的流水线

的java.lang。 UnsupportedOperationException异常:管道是目前不 支持JedisClusterConnection

什么是我的另类

EDIT1:?

protected void store(Map<String,Creative> creativesToStore, Function<Map<String,Creative>,Object> executedAction) 
{ 
    this.redisTemplate.execute(
      redisConnection -> executedAction.apply(creativesToStore), true, true); // Pipelined execution*/ 

} 

protected Object storeAllCreativesRedis(Map<String,Creative> creativesToStore) 
{ 
    creativesToStore.keySet() 
      .stream() 
      .filter(key -> creativesToStore.get(key)!=null) 
      .forEach(key -> { 
       redisTemplate.opsForValue().set(key, creativesToStore.get(key), ttlSeconds, timeUnit); 
       logger.debug("Issuing a redis set for %s ",key); 
      }); 
    return null; 
} 
+1

分享你的代码,不只是例外? – alzee

+0

您可以连接到您的密钥所在的节点并直接使用流水线。 – mp911de

+0

您可以举例说明如何连接到群集中的单个节点吗? –

回答

1

您是否尝试过Redisson框架?它支持集群模式下的Redis管道。

+1

尽管这个链接可能回答这个问题,但最好在这里包含答案的基本部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/18950900) –