I am having a batch query in redis 6.x, this is the java code looks like:
private List<Object> fetchBatch(List<Long> ids){ Set keySet = new HashSet(); ids.forEach(id ->{ String cachedKey = articleDetailKey + id; keySet.add(cachedKey); }); List<Object> values = articleRedisTemplate.opsForHash().multiGet("articles", keySet); if(values.size() != keySet.size()){ log.error("batch fetch size not match"); } return values; }
this code batch query the articles by keys collection from redis, now I am facing a problem is that the query was not stable. sometimes it takes 15ms, sometimes it takes 60ms, sometimes it take 100+ ms or 200+ms. is it possible to make the redis query more stable? I want to make the redis return result less than 10ms every time. The article id number is 10-20, the redis cluster was in deployment in kubernetes.