我需要了解你的代码:
首先,你为什么要检查是否计数!= null?不是oldCountIdValue == null意味着count == null,反之亦然:如果oldCountIdValue!= null则count!= null
若是,则代码应为:
IdentifiableValue oldCountIdValue = mc.getIdentifiable( cacheKey );
if (oldCountIdValue != null) {
return ( Long ) oldCountIdValue.getValue();
}
Long result = new Long( q.count() );
mc.putIfUntouched( cacheKey, oldCountValue, result );
return result;
</code>
如果putIfUntouched返回null,则表示结果变量不再准确,您可以执行以下操作:忽略并返回当前结果或从缓存中加载结果。