避免缓存雪崩
This commit is contained in:
parent
b98819cc74
commit
9f8de780fd
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package top.peng.answerbi.manager;
|
package top.peng.answerbi.manager;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
@ -55,7 +56,7 @@ public class MybatisRedisCacheManager implements Cache {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void putObject(Object key, Object value) {
|
public void putObject(Object key, Object value) {
|
||||||
getRedisTemplate().opsForValue().set(key.toString(), value, EXPIRE_TIME_IN_MINUTES, TimeUnit.MINUTES);
|
getRedisTemplate().opsForValue().set(key.toString(), value, EXPIRE_TIME_IN_MINUTES + RandomUtil.randomInt(10), TimeUnit.MINUTES);
|
||||||
log.info("Put query result to redis, key={}",key);
|
log.info("Put query result to redis, key={}",key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user