Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

how to make the redis batch key query more stable

$
0
0

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.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>