com.turbospaces.ebean.LocalEbeanCache Maven / Gradle / Ivy
package com.turbospaces.ebean;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.lang3.exception.ExceptionUtils;
import com.google.common.collect.ImmutableSet;
import com.turbospaces.cache.BlockhoundCacheWrapper;
import com.turbospaces.cfg.ApplicationProperties;
import io.ebean.cache.ServerCacheConfig;
import io.ebean.config.CurrentTenantProvider;
public class LocalEbeanCache extends AbstractEbeanCache {
private final BroadcastChannel dispatcher;
public LocalEbeanCache(
ApplicationProperties props,
String cacheKey,
BlockhoundCacheWrapper cache,
CurrentTenantProvider tenantProvider,
ServerCacheConfig config,
BroadcastChannel dispatcher) {
super(props, cacheKey, cache, tenantProvider, config);
this.dispatcher = Objects.requireNonNull(dispatcher);
}
@Override
public void put(Object id, Object obj) {
String key = key(id);
super.put(id, obj);
try {
dispatcher.broadcastRemoveAsync(cacheKey(), key);
} catch (Throwable err) {
ExceptionUtils.wrapAndThrow(err);
}
}
@Override
public void putAll(Map