[英]Redis Pfcount in Cluster Mode
我遇到以下錯誤,Redis迫使我對同一節點上的鍵進行計數。 Redis中是否有新的現代方法來處理此不足功能?
org.springframework.dao.InvalidDataAccessApiUsageException: All keys must map to same slot for pfcount in cluster mode.
at org.springframework.data.redis.connection.jedis.JedisClusterConnection.pfCount(JedisClusterConnection.java:3610)
at org.springframework.data.redis.core.DefaultHyperLogLogOperations$2.doInRedis(DefaultHyperLogLogOperations.java:68)
at org.springframework.data.redis.core.DefaultHyperLogLogOperations$2.doInRedis(DefaultHyperLogLogOperations.java:64)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:207)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:169)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:91)
at org.springframework.data.redis.core.DefaultHyperLogLogOperations.size(DefaultHyperLogLogOperations.java:64)
彈簧源代碼:
@Override
public long countAll(List<String> keys) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
LOGGER.debug("Calculating keys -> {} ", keys);
long size = 0;
try {
size = hyperLogLogOperations.size(keys.toArray(new String[0]));
redisInTrouble = false;
} catch (Exception e) {
LOGGER.error("Having Redis Error with key: {}", keys, e);
redisInTrouble = true;
} finally {
metricObserver.observe(SummaryMetric.REDIS_RESPONSE_PFCOUNT_TIME, stopWatch.getTotalTimeMillis());
stopOrStartKafkaUpOnRedisError();
}
return size;
}
這是redis-cli提示:
172.18.182.82:6379> pfcount XMPP-LI-09270934
(integer) 4
172.18.182.82:6379> pfcount XMPP-LI-09270936
(error) MOVED 3842 172.18.182.82:7379
172.18.182.82:6379> pfcount XMPP-LI-09270936 XMPP-LI-09270934
(error) CROSSSLOT Keys in request don't hash to the same slot
通過將密鑰括在{}中,強制密鑰位於同一插槽中。 例如, pfcount {XMPP-LI}-09270936 {XMPP-LI}-09270934
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.