@Autowired
protected StringRedisTemplate redisTemplate;
public List<ContactsCustomAttribute> queryList(String userId, Integer type) {
String key = STAGE_LIST_KEY_STAGE + userId + "_" + type;
String attribute = redisTemplate.opsForValue().get(key);
if (StringUtil.isNotBlank(attribute)) {
List<ContactsCustomAttribute> contactsCustomAttributes = JsonUtil.fromJsonString(attribute, new TypeReference<List<ContactsCustomAttribute>>() {
});
return contactsCustomAttributes;
}
List<ContactsCustomAttribute> contactsCustomAttributes = contactsCustomAttributeDao.queryList(userId, type);
redisTemplate.opsForValue().set(key, JsonUtil.toJsonString(contactsCustomAttributes), EXPIRATION_TIME, TimeUnit.MINUTES);
return contactsCustomAttributes;
}