#1225 - ENH: Extend L2 server cache (near caching) for clearing "near caches"

This commit is contained in:
Rob Bygrave
2017-12-13 02:09:10 +13:00
parent 69c045443c
commit c7f4b56dd1
23 changed files with 585 additions and 65 deletions
@@ -2,6 +2,7 @@ package io.ebeaninternal.server.transaction;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.TransactionEventTable.TableIUD;
import io.ebeaninternal.server.cache.RemoteCacheEvent;
import io.ebeaninternal.server.cluster.BinaryMessageList;
import java.io.IOException;
@@ -16,6 +17,8 @@ public class RemoteTransactionEvent implements Runnable {
private DeleteByIdMap deleteByIdMap;
private RemoteCacheEvent remoteCacheEvent;
private String serverName;
private transient SpiEbeanServer server;
@@ -65,6 +68,9 @@ public class RemoteTransactionEvent implements Runnable {
for (BeanPersistIds aBeanPersistList : beanPersistList) {
aBeanPersistList.writeBinaryMessage(msgList);
}
if (remoteCacheEvent != null) {
remoteCacheEvent.writeBinaryMessage(msgList);
}
}
public boolean isEmpty() {
@@ -77,6 +83,29 @@ public class RemoteTransactionEvent implements Runnable {
beanPersistList.add(beanPersist);
}
/**
* Add a cache clearAll event.
*/
public RemoteTransactionEvent cacheClearAll() {
this.remoteCacheEvent = new RemoteCacheEvent(true);
return this;
}
/**
* Add a cache clear event for the given bean type.
*/
public RemoteTransactionEvent cacheClear(Class<?> beanType) {
this.remoteCacheEvent = new RemoteCacheEvent(beanType);
return this;
}
/**
* Set the RemoteCacheEvent.
*/
public void addRemoteCacheEvent(RemoteCacheEvent remoteCacheEvent) {
this.remoteCacheEvent = remoteCacheEvent;
}
public void addTableIUD(TableIUD tableIud) {
if (tableList == null) {
tableList = new ArrayList<>(4);
@@ -108,4 +137,8 @@ public class RemoteTransactionEvent implements Runnable {
return beanPersistList;
}
public RemoteCacheEvent getRemoteCacheEvent() {
return remoteCacheEvent;
}
}