private void cacheToRedis(String key, List<String> list, int month) {
if (list == null || list.isEmpty()) {
return;
}
String tempKey = UUID.randomUUID().toString();
Boolean hasKey = stringRedisTemplate.hasKey(key);
if (hasKey != null && hasKey) {
stringRedisTemplate.rename(key, tempKey);
stringRedisTemplate.unlink(tempKey);
}
stringRedisTemplate.opsForSet().add(key, list.toArray(new String[0]));
Calendar instance = Calendar.getInstance();
instance.add(Calendar.MONTH, month);
stringRedisTemplate.expireAt(key, instance.getTime());
}
07-01
740