提交 c4def34a authored 作者: Sergi Vladykin's avatar Sergi Vladykin

Reverted synchronization from query cache

上级 877c03fb
...@@ -43,7 +43,7 @@ public abstract class Command implements CommandInterface { ...@@ -43,7 +43,7 @@ public abstract class Command implements CommandInterface {
private final String sql; private final String sql;
private volatile boolean canReuse; private boolean canReuse;
Command(Parser parser, String sql) { Command(Parser parser, String sql) {
this.session = parser.getSession(); this.session = parser.getSession();
......
...@@ -116,7 +116,7 @@ public class Session extends SessionWithState { ...@@ -116,7 +116,7 @@ public class Session extends SessionWithState {
private int modificationId; private int modificationId;
private int objectId; private int objectId;
private final int queryCacheSize; private final int queryCacheSize;
private final SmallLRUCache<String, Command> queryCache; private SmallLRUCache<String, Command> queryCache;
private long modificationMetaID = -1; private long modificationMetaID = -1;
private SubQueryInfo subQueryInfo; private SubQueryInfo subQueryInfo;
private int parsingView; private int parsingView;
...@@ -149,9 +149,6 @@ public class Session extends SessionWithState { ...@@ -149,9 +149,6 @@ public class Session extends SessionWithState {
this.database = database; this.database = database;
this.queryTimeout = database.getSettings().maxQueryTimeout; this.queryTimeout = database.getSettings().maxQueryTimeout;
this.queryCacheSize = database.getSettings().queryCacheSize; this.queryCacheSize = database.getSettings().queryCacheSize;
this.queryCache = queryCacheSize <= 0 ? null :
SmallLRUCache.<String, Command>newInstance(queryCacheSize);
this.modificationMetaID = database.getModificationMetaId();
this.undoLog = new UndoLog(this); this.undoLog = new UndoLog(this);
this.user = user; this.user = user;
this.id = id; this.id = id;
...@@ -554,8 +551,11 @@ public class Session extends SessionWithState { ...@@ -554,8 +551,11 @@ public class Session extends SessionWithState {
"session closed"); "session closed");
} }
Command command; Command command;
if (queryCache != null) { if (queryCacheSize > 0) {
synchronized (queryCache) { if (queryCache == null) {
queryCache = SmallLRUCache.newInstance(queryCacheSize);
modificationMetaID = database.getModificationMetaId();
} else {
long newModificationMetaID = database.getModificationMetaId(); long newModificationMetaID = database.getModificationMetaId();
if (newModificationMetaID != modificationMetaID) { if (newModificationMetaID != modificationMetaID) {
queryCache.clear(); queryCache.clear();
...@@ -576,8 +576,8 @@ public class Session extends SessionWithState { ...@@ -576,8 +576,8 @@ public class Session extends SessionWithState {
subQueryIndexCache = null; subQueryIndexCache = null;
} }
command.prepareJoinBatch(); command.prepareJoinBatch();
if (queryCache != null && command.isCacheable()) { if (queryCache != null) {
synchronized (queryCache) { if (command.isCacheable()) {
queryCache.put(sql, command); queryCache.put(sql, command);
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论