mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1427 - Map all deleteByIds into a single CacheChangeBeanRemove and use bulk removeAll api to remove from cache
This commit is contained in:
@@ -2,6 +2,9 @@ package io.ebeaninternal.server.cache;
|
||||
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Change to remove bean from L2 cache.
|
||||
*/
|
||||
@@ -9,15 +12,35 @@ class CacheChangeBeanRemove implements CacheChange {
|
||||
|
||||
private final BeanDescriptor<?> descriptor;
|
||||
|
||||
private final Object id;
|
||||
private final Collection<Object> ids;
|
||||
|
||||
CacheChangeBeanRemove(BeanDescriptor<?> descriptor, Object id) {
|
||||
CacheChangeBeanRemove(Object id, BeanDescriptor<?> descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
this.id = id;
|
||||
this.ids = new ArrayList<>();
|
||||
ids.add(id);
|
||||
}
|
||||
|
||||
CacheChangeBeanRemove(BeanDescriptor<?> descriptor, Collection<Object> ids) {
|
||||
this.descriptor = descriptor;
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
descriptor.cacheHandleDeleteById(id);
|
||||
descriptor.cacheApplyInvalidate(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add more id values.
|
||||
*/
|
||||
public void addIds(Collection<Object> moreIds) {
|
||||
ids.addAll(moreIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another id value.
|
||||
*/
|
||||
public void addId(Object id) {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user