public void setHash(String key,Map<String,String> map){
redisTemplate.opsForHash().putAll(key, map);
}
public Map<String,String> getHash(String key){
return redisTemplate.opsForHash().entries(key);
}
//从redis里面取map
Map<String,String> map=redisService.getHash(String.valueOf(coreProductId));
//往redis里面存map
if(map==null || map.size()==0){
List<CoreTravelPremiumRules> coreTravelPremiumRules=premiumCorrelationMapper.selectProductRate(String.valueOf(coreProductId));
if(CollectionUtils.isEmpty(coreTravelPremiumRules)) return new BaseResDto(ErrorEnum.RATE_IS_NULL_EXCEPTION);
map = new HashMap<>();
for (CoreTravelPremiumRules coreTravelPremiumRule : coreTravelPremiumRules) {
StringJoiner sj = new StringJoiner("_");
sj.add(coreTravelPremiumRule.getPlanCode()).add(String.valueOf(coreTravelPremiumRule.getMinimumDay())).add(String.valueOf(coreTravelPremiumRule.getMaximumDay())).add(coreTravelPremiumRule.getDayType()).add(String.valueOf(coreTravelPremiumRule.getMinimumAge())).add(coreTravelPremiumRule.getMinimumAgeType()).add(String.valueOf(coreTravelPremiumRule.getMaximumAge())).add(coreTravelPremiumRule.getMaximumAgeType());
map.put(sj.toString().replace(" ",""), String.valueOf(coreTravelPremiumRule.getPrice()));
}
redisService.setHash(String.valueOf(coreProductId),map);
}
//在redis中存list
redisHelper.addRedisCache(RedisKey.RISK_RATE_REDISKEY+"_"+riskId,JSON.toJSON(list).toString());
//从redis中取list
List<TagsAndCompanyDTO> rateList =null;
String resul = (String) redisHelper.getRedisCache(RedisKey.RISK_RATE_REDISKEY+"_"+riskId,String.class);
if(StringUtils.isNotBlank(resul)){
rateList = JSON.parseArray(resul,TagsAndCompanyDTO.class);
redisHelper.delRedisCache(RedisKey.RISK_RATE_REDISKEY+"_"+riskId);
}