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);