mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
#734 - Add ServerConfig.skipCacheAfterWrite & transaction.setSkipCache(boolean) ... to control L2 Bean cache use during transaction
This commit is contained in:
1 parent
c24ee53462
commit
a64a020e36
10 files changed
+290
-17
No files matched your search
@@ -4,6 +4,7 @@ import com.avaje.ebean.TransactionCallback;
|
||||
import com.avaje.ebean.annotation.DocStoreMode;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebean.config.PersistBatch;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform.OnQueryOnly;
|
||||
import com.avaje.ebean.event.changelog.BeanChange;
|
||||
import com.avaje.ebean.event.changelog.ChangeSet;
|
||||
@@ -151,6 +152,16 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
|
||||
protected int docStoreBatchSize;
|
||||
|
||||
/**
|
||||
* Explicit control over skipCache.
|
||||
*/
|
||||
protected Boolean skipCache;
|
||||
|
||||
/**
|
||||
* Default skip cache behavior from {@link ServerConfig#isSkipCacheAfterWrite()}.
|
||||
*/
|
||||
protected final boolean skipCacheAfterWrite;
|
||||
|
||||
/**
|
||||
* Create a new JdbcTransaction.
|
||||
*/
|
||||
@@ -162,11 +173,20 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
this.explicit = explicit;
|
||||
this.manager = manager;
|
||||
this.connection = connection;
|
||||
this.batchMode = manager == null ? PersistBatch.NONE : manager.getPersistBatch();
|
||||
this.batchOnCascadeMode = manager == null ? PersistBatch.NONE : manager.getPersistBatchOnCascade();
|
||||
this.onQueryOnly = manager == null ? OnQueryOnly.ROLLBACK : manager.getOnQueryOnly();
|
||||
this.persistenceContext = new DefaultPersistenceContext();
|
||||
|
||||
if (manager == null) {
|
||||
this.skipCacheAfterWrite = true;
|
||||
this.batchMode = PersistBatch.NONE;
|
||||
this.batchOnCascadeMode = PersistBatch.NONE;
|
||||
this.onQueryOnly = OnQueryOnly.ROLLBACK;
|
||||
} else {
|
||||
this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite();
|
||||
this.batchMode = manager.getPersistBatch();
|
||||
this.batchOnCascadeMode = manager.getPersistBatchOnCascade();
|
||||
this.onQueryOnly = manager.getOnQueryOnly();
|
||||
}
|
||||
|
||||
checkAutoCommit(connection);
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -197,6 +217,17 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSkipCache() {
|
||||
if (skipCache != null) return skipCache;
|
||||
return skipCacheAfterWrite && !queryOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkipCache(boolean skipCache) {
|
||||
this.skipCache = skipCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLogPrefix() {
|
||||
return logPrefix;
|
||||
|
||||
Reference in new issue
Block a user