
org.infinispan.client.hotrod.HotRodAsyncCaches Maven / Gradle / Ivy
package org.infinispan.client.hotrod;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import org.infinispan.api.Experimental;
import org.infinispan.api.async.AsyncCache;
import org.infinispan.api.async.AsyncCaches;
import org.infinispan.api.configuration.CacheConfiguration;
import org.infinispan.client.hotrod.impl.InternalRemoteCache;
import org.infinispan.commons.util.concurrent.CompletableFutures;
/**
* @since 14.0
**/
@Experimental
final class HotRodAsyncCaches implements AsyncCaches {
private final HotRod hotrod;
HotRodAsyncCaches(HotRod hotrod) {
this.hotrod = hotrod;
}
@Override
public CompletionStage> get(String name) {
InternalRemoteCache cache = getCache(name);
return CompletableFuture.completedFuture(new HotRodAsyncCache<>(hotrod, cache));
}
@Override
public CompletionStage> create(String name, CacheConfiguration cacheConfiguration) {
hotrod.cacheManager.getConfiguration().addRemoteCache(name, builder -> builder.configuration(cacheConfiguration.toString()));
return get(name);
}
@Override
public CompletionStage> create(String name, String template) {
throw new UnsupportedOperationException();
}
@Override
public CompletionStage remove(String name) {
hotrod.cacheManager.administration().removeCache(name);
return CompletableFutures.completedNull();
}
@Override
public CompletionStage> names() {
return CompletableFuture.completedFuture(hotrod.cacheManager.getCacheNames());
}
@Override
public CompletionStage createTemplate(String name, CacheConfiguration cacheConfiguration) {
throw new UnsupportedOperationException();
}
@Override
public CompletionStage removeTemplate(String name) {
throw new UnsupportedOperationException();
}
@Override
public CompletionStage> templateNames() {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
private InternalRemoteCache getCache(String name) {
return (InternalRemoteCache) hotrod.cacheManager.getCache(name);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy