gpt4 book ai didi

java - 集群模式下的 Redis Pfcount

转载 作者:可可西里 更新时间:2023-11-01 11:24:13 25 4
gpt4 key购买 nike

我有以下错误,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)

Spring 源代码:

@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

关于java - 集群模式下的 Redis Pfcount,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52607154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com