以下是导致标题出现问题的代码:
private void getImageFromCache (List<String> skuCodes, Map<String,String> ret) {
RMapCache<String,String> imageCache = redissonClient.getMapCache(Constant.SKU_IMAGES_KEY);
for (String sku : skuCodes){
if (imageCache.containsKey(sku)){
ret.put(sku,imageCache.get(sku)); // this code cause the problem
}
}
skuCodes.removeAll(ret.keySet());
}
我终于找到了解决问题的方法:
private void getImageFromCache (List<String> skuCodes, Map<String,String> ret) {
RMapCache<String,String> imageCache = redissonClient.getMapCache(Constant.SKU_IMAGES_KEY);
Map<String, String> valueMap = imageCache.getAll(new HashSet<>(skuCodes));
ret.putAll(valueMap);
skuCodes.removeAll(ret.keySet());
}
redison版本:
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.8.0</version>
</dependency>
它只有大约1k大小的imageCache。
我想弄清楚为什么,以及redison在调用RMapCache的get()时做了什么。
谢谢