首页 > 编程语言 > 详细

Java使用redis存取集合对象

时间:2021-06-24 10:34:43      阅读:15      评论:0      收藏:0      [点我收藏+]

List

使用Java存取List对象,将list转为json对象进行存取

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
 
 
  @Autowired
    private StringRedisTemplate stringRedisTemplate;
 
//存
List<Long> businessIdList = eeFreecarriageShopService.selectBusinessIdInPromotion();
 stringRedisTemplate.opsForValue().set(RedisConstants.FREECARRIAGE_BUSINESSIDLIST, JSON.toJSON(businessIdList).toString());
 
//取
String businessJsonArray = stringRedisTemplate.opsForValue().get(RedisConstants.FREECARRIAGE_BUSINESSIDLIST);
List<Long> businessIdList = JSONObject.parseArray(businessJsonArray, Long.class);

Java使用redis存取集合对象

原文:https://www.cnblogs.com/hnxbp/p/14925422.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!