@PostMapping("/testHashmapCache")
@ApiOperation(value = "使用hashmap实现数据缓存(交易计算结果列表)",notes = "使用hashmap实现数据缓存")
public RespEntity useHashmapCacheData(@RequestHeader("ticket") String ticket,
@RequestBody TsTransResult tsTransResult){
RespEntity resp = new RespEntity();
HashMap<String,TsTransResult> map1 = new HashMap<>();
map1.clear();
String key = Integer.toString(map1.size());
map1.putIfAbsent(key,tsTransResult);
if (map1 != null && map1.size()>0) {
Iterator<Map.Entry<String, TsTransResult>> it = map1.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, TsTransResult> entry = it.next();
}
}
return resp.success(map1);
}
使用hashmap实现单个对象的缓存
最新推荐文章于 2024-01-04 15:30:17 发布