You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
protected void addToCleaner() {
// When the cache size is small, it can be stored in memory for a long time
if (config.getLimit() > 256) {
Cleaner.add(this);
}
}
LinkedHashMapCache使用LinkedHashMap实现,实例化时会固定传入
accessOrder=true
,当accessOrder为true时访问数据后会将当前节点移到队列尾部,当过期策略设置为isExpireAfterAccess时没有问题,最近访问的数据会放到队尾那么队列头部均是最早被淘汰的,但是当过期策略是isExpireAfterWrite时就会因这些移尾的行为打乱进入队列的位置,队列头部的数据并不能保证优先被淘汰,只有保留入队顺序才能更快的找到淘汰数据,所以需要根据config里的过期策略来设计accessOrder的值。优化建议:
另外建议LinkedHashMapAutoConfiguration添加map关键词,linkedhashmap名称太长且不需要向外暴露实现方法,改为map更简洁且不容易拼写错误
The text was updated successfully, but these errors were encountered: