mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1225 - ENH: Extend L2 server cache (near caching) for clearing "near caches"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user