fix cache bug

This commit is contained in:
Looly
2020-12-04 09:42:58 +08:00
parent 6c76e9258b
commit 8d81a59666
3 changed files with 7 additions and 7 deletions

View File

@@ -10,6 +10,7 @@
* 【core 】 multipart中int改为long解决大文件上传越界问题issue#I27WZ3@Gitee * 【core 】 multipart中int改为long解决大文件上传越界问题issue#I27WZ3@Gitee
### Bug修复 ### Bug修复
* 【cache 】 修复Cache中get重复misCount计数问题issue#1281@Github
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------

View File

@@ -15,7 +15,7 @@ import java.util.concurrent.locks.StampedLock;
* 继承此抽象缓存需要:<br> * 继承此抽象缓存需要:<br>
* <ul> * <ul>
* <li>创建一个新的Map</li> * <li>创建一个新的Map</li>
* <li>实现 <code>prune</code> 策略</li> * <li>实现 {@code prune} 策略</li>
* </ul> * </ul>
* *
* @param <K> 键类型 * @param <K> 键类型
@@ -30,11 +30,11 @@ public abstract class AbstractCache<K, V> implements Cache<K, V> {
private final StampedLock lock = new StampedLock(); private final StampedLock lock = new StampedLock();
/** /**
* 返回缓存容量,<code>0</code>表示无大小限制 * 返回缓存容量,{@code 0}表示无大小限制
*/ */
protected int capacity; protected int capacity;
/** /**
* 缓存失效时长, <code>0</code> 表示无限制,单位毫秒 * 缓存失效时长, {@code 0} 表示无限制,单位毫秒
*/ */
protected long timeout; protected long timeout;
@@ -168,10 +168,8 @@ public abstract class AbstractCache<K, V> implements Cache<K, V> {
return null; return null;
} }
if (co.isExpired()) { // 命中
missCount.getAndIncrement(); if (false == co.isExpired()) {
} else {
// 命中
hitCount.getAndIncrement(); hitCount.getAndIncrement();
return co.get(isUpdateLastAccess); return co.get(isUpdateLastAccess);
} }

View File

@@ -19,6 +19,7 @@ import java.sql.SQLException;
* @author Luxiaolei * @author Luxiaolei
* *
*/ */
@FunctionalInterface
public interface RsHandler<T> extends Serializable{ public interface RsHandler<T> extends Serializable{
/** /**