diff --git a/pom.xml b/pom.xml
index 69b656d2..2676b7d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,6 +128,11 @@
compile
true
+
+ org.slf4j
+ slf4j-api
+ 1.7.32
+
junit
diff --git a/src/main/java/com/github/pagehelper/dialect/AbstractHelperDialect.java b/src/main/java/com/github/pagehelper/dialect/AbstractHelperDialect.java
index fa30ad4c..c3e3fec3 100644
--- a/src/main/java/com/github/pagehelper/dialect/AbstractHelperDialect.java
+++ b/src/main/java/com/github/pagehelper/dialect/AbstractHelperDialect.java
@@ -24,10 +24,15 @@
package com.github.pagehelper.dialect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.github.pagehelper.Constant;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageRowBounds;
+import com.github.pagehelper.cache.Cache;
+import com.github.pagehelper.cache.CacheFactory;
import com.github.pagehelper.util.ExecutorUtil;
import com.github.pagehelper.util.MetaObjectUtil;
import com.github.pagehelper.util.StringUtil;
@@ -48,6 +53,16 @@
* @since 2016-12-04 14:32
*/
public abstract class AbstractHelperDialect extends AbstractDialect implements Constant {
+ /**
+ * Logger for this class.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(AbstractHelperDialect.class);
+
+ protected Cache CACHE_COUNTSQL;
+ protected Cache CACHE_PAGESQL;
+
+ public static boolean cacheOnFlag = true;// 临时性开关,为了方便切换,以验证缓存前后对比.
+ public static boolean tracingOn = false;// 临时性开关
/**
* 获取分页参数
@@ -61,7 +76,7 @@ public Page getLocalPage() {
@Override
public final boolean skip(MappedStatement ms, Object parameterObject, RowBounds rowBounds) {
- //该方法不会被调用
+ // 该方法不会被调用
return true;
}
@@ -72,13 +87,48 @@ public boolean beforeCount(MappedStatement ms, Object parameterObject, RowBounds
}
@Override
- public String getCountSql(MappedStatement ms, BoundSql boundSql, Object parameterObject, RowBounds rowBounds, CacheKey countKey) {
+ public String getCountSql(MappedStatement ms, BoundSql boundSql, Object parameterObject, RowBounds rowBounds,
+ CacheKey countKey) {
+ final long startTime = tracingOn || logger.isDebugEnabled() ? System.nanoTime() : 0;
+ if (startTime > 0) {
+ logger.info("getCountSql start ...");
+ }
Page