mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 14:40:46 +00:00
#1427 - QueryCache should be cleared, if one of a dependent bean is updated
Wrap Clock as ClockService to use in TransactionManager and DefaultServer (and allow for changing the Clock implementation for testing).
This commit is contained in:
1 parent
5adbebaf6e
commit
bd3c99e67f
7 files changed
+53
-11
No files matched your search
@@ -80,7 +80,7 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
this.connection = connection;
|
||||
this.persistenceContext = new DefaultPersistenceContext();
|
||||
this.startNanos = System.nanoTime();
|
||||
this.startMillis = manager.clockNowEpoch();
|
||||
this.startMillis = manager.clockNowMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -212,7 +212,7 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
this.batchOnCascadeMode = PersistBatch.NONE;
|
||||
this.onQueryOnly = OnQueryOnly.ROLLBACK;
|
||||
} else {
|
||||
this.startMillis = manager.clockNowEpoch();
|
||||
this.startMillis = manager.clockNowMillis();
|
||||
this.logSql = manager.isLogSql();
|
||||
this.logSummary = manager.isLogSummary();
|
||||
this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite();
|
||||
|
||||
@@ -29,6 +29,7 @@ import io.ebeaninternal.metric.MetricFactory;
|
||||
import io.ebeaninternal.metric.TimedMetric;
|
||||
import io.ebeaninternal.metric.TimedMetricMap;
|
||||
import io.ebeaninternal.server.cluster.ClusterManager;
|
||||
import io.ebeaninternal.server.core.ClockService;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
import io.ebeaninternal.server.profile.TimedProfileLocation;
|
||||
import io.ebeaninternal.server.profile.TimedProfileLocationRegistry;
|
||||
@@ -140,6 +141,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
|
||||
private final TableModState tableModState;
|
||||
private final ServerCacheNotify cacheNotify;
|
||||
private final ClockService clockService;
|
||||
|
||||
/**
|
||||
* Create the TransactionManager
|
||||
@@ -164,6 +166,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
this.scopeManager = options.scopeManager;
|
||||
this.tableModState = options.tableModState;
|
||||
this.cacheNotify = options.cacheNotify;
|
||||
this.clockService = options.clockService;
|
||||
this.backgroundExecutor = options.backgroundExecutor;
|
||||
this.dataSourceSupplier = options.dataSourceSupplier;
|
||||
this.docStoreActive = options.config.getDocStoreConfig().isActive();
|
||||
@@ -188,8 +191,8 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
/**
|
||||
* Return the NOW timestamp in epoch millis.
|
||||
*/
|
||||
public long clockNowEpoch() {
|
||||
return System.currentTimeMillis(); // TODO: Review when we supply a Clock via ServerConfig.
|
||||
public long clockNowMillis() {
|
||||
return clockService.nowMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -448,7 +451,7 @@ public class TransactionManager implements SpiTransactionManager {
|
||||
|
||||
private void externalModificationEvent(TransactionEventTable tableEvents) {
|
||||
|
||||
TransactionEvent event = new TransactionEvent(clockNowEpoch());
|
||||
TransactionEvent event = new TransactionEvent(clockNowMillis());
|
||||
event.add(tableEvents);
|
||||
|
||||
PostCommitProcessing postCommit = new PostCommitProcessing(clusterManager, this, event);
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.ebean.config.ServerConfig;
|
||||
import io.ebeaninternal.api.SpiLogManager;
|
||||
import io.ebeaninternal.api.SpiProfileHandler;
|
||||
import io.ebeaninternal.server.cluster.ClusterManager;
|
||||
import io.ebeaninternal.server.core.ClockService;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptorManager;
|
||||
import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
|
||||
|
||||
@@ -27,12 +28,13 @@ public class TransactionManagerOptions {
|
||||
final SpiLogManager logManager;
|
||||
final TableModState tableModState;
|
||||
final ServerCacheNotify cacheNotify;
|
||||
final ClockService clockService;
|
||||
|
||||
|
||||
public TransactionManagerOptions(boolean notifyL2CacheInForeground, ServerConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager,
|
||||
BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor,
|
||||
BeanDescriptorManager descMgr, DataSourceSupplier dataSourceSupplier, SpiProfileHandler profileHandler,
|
||||
SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify) {
|
||||
SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify, ClockService clockService) {
|
||||
|
||||
this.notifyL2CacheInForeground = notifyL2CacheInForeground;
|
||||
this.config = config;
|
||||
@@ -46,6 +48,7 @@ public class TransactionManagerOptions {
|
||||
this.logManager = logManager;
|
||||
this.tableModState = tableModState;
|
||||
this.cacheNotify = cacheNotify;
|
||||
this.clockService = clockService;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user