mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Optimize LRU Algorithm
This commit is contained in:
@@ -88,7 +88,6 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
}
|
||||
|
||||
if (holder.isPoolPreparedStatements()) {
|
||||
this.holder.getStatementPool().put(stmt.getPreparedStatementHolder());
|
||||
stmt.clearResultSet();
|
||||
holder.removeTrace(stmt);
|
||||
stmt.setClosed(true); // soft set close
|
||||
@@ -156,6 +155,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
try {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareStatement(sql));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -190,6 +190,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareStatement(sql, resultSetType,
|
||||
resultSetConcurrency));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -225,6 +226,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
resultSetConcurrency,
|
||||
resultSetHoldability));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -256,6 +258,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
try {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareStatement(sql, columnIndexes));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -287,6 +290,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
try {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareStatement(sql, columnNames));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -318,6 +322,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
try {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareStatement(sql, autoGeneratedKeys));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -352,6 +357,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
try {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareCall(sql));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -386,6 +392,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
resultSetConcurrency,
|
||||
resultSetHoldability));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -418,6 +425,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
stmtHolder = new PreparedStatementHolder(key, conn.prepareCall(sql, resultSetType,
|
||||
resultSetConcurrency));
|
||||
holder.getDataSource().incrementPreparedStatementCount();
|
||||
holder.getStatementPool().put(stmtHolder);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user