#638 - ENH: Add Apache Ignite as L2 cache option

This commit is contained in:
Robin Bygrave
2016-04-08 02:03:02 +12:00
parent 524be4ce55
commit da90eccc12
4 changed files with 31 additions and 1 deletions
@@ -46,4 +46,9 @@ public interface SpiServer extends EbeanServer {
* Return the associated DataSource for this EbeanServer instance.
*/
DataSource getDataSource();
/**
* Initialise the query cache for the given bean type.
*/
boolean initQueryCache(String key);
}
@@ -2030,6 +2030,16 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return beanDescriptorManager.getBeanDescriptorByClassName(beanClassName);
}
@Override
public boolean initQueryCache(String key) {
BeanDescriptor<?> desc = getBeanDescriptorById(key);
if (desc != null) {
desc.queryCacheInit();
return true;
}
return false;
}
/**
* Another server in the cluster sent this event so that we can inform local
* BeanListeners of inserts updates and deletes that occurred remotely (on
@@ -1075,6 +1075,10 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
return cacheHelp.isCacheNotify();
}
public void queryCacheInit() {
cacheHelp.queryCacheInit();
}
/**
* Clear the query cache.
*/
@@ -59,7 +59,7 @@ public final class BeanDescriptorCacheHelp<T> {
private ServerCache beanCache;
private ServerCache naturalKeyCache;
private ServerCache queryCache;
private volatile ServerCache queryCache;
public BeanDescriptorCacheHelp(BeanDescriptor<T> desc, ServerCacheManager cacheManager, CacheOptions cacheOptions,
boolean cacheSharableBeans, BeanPropertyAssocOne<?>[] propertiesOneImported) {
@@ -148,6 +148,17 @@ public final class BeanDescriptorCacheHelp<T> {
return cacheOptions;
}
/**
* Initialise the query cache if required
* (as some node in the cluster already has it).
*/
public void queryCacheInit() {
if (queryCache == null) {
queryLog.debug(" init {}", cacheName);
queryCache = cacheManager.getQueryCache(beanType);
}
}
/**
* Clear the query cache.
*/