All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.client.hotrod.HotRodSyncCaches Maven / Gradle / Ivy

package org.infinispan.client.hotrod;

import org.infinispan.api.Experimental;
import org.infinispan.api.configuration.CacheConfiguration;
import org.infinispan.api.sync.SyncCache;
import org.infinispan.api.sync.SyncCaches;
import org.infinispan.client.hotrod.impl.InternalRemoteCache;

/**
 * @since 14.0
 **/
@Experimental
final class HotRodSyncCaches implements SyncCaches {
   private final HotRod hotrod;

   HotRodSyncCaches(HotRod hotrod) {
      this.hotrod = hotrod;
   }

   @Override
   public  SyncCache get(String name) {
      InternalRemoteCache cache = getCache(name);
      return new HotRodSyncCache<>(hotrod, cache);
   }

   @Override
   public  SyncCache create(String name, CacheConfiguration cacheConfiguration) {
      hotrod.cacheManager.getConfiguration().addRemoteCache(name, builder -> builder.configuration(cacheConfiguration.toString()));
      return get(name);
   }

   @Override
   public  SyncCache create(String name, String template) {
      hotrod.cacheManager.getConfiguration().addRemoteCache(name, builder -> builder.templateName(template));
      return get(name);
   }

   @Override
   public void remove(String name) {
      hotrod.cacheManager.administration().removeCache(name);
   }

   @Override
   public Iterable names() {
      return hotrod.cacheManager.getCacheNames();
   }

   @Override
   public void createTemplate(String name, CacheConfiguration cacheConfiguration) {
      throw new UnsupportedOperationException();
   }

   @Override
   public void removeTemplate(String name) {
      throw new UnsupportedOperationException();
   }

   @Override
   public Iterable templateNames() {
      throw new UnsupportedOperationException();
   }

   @SuppressWarnings("unchecked")
   private  InternalRemoteCache getCache(String name) {
      return (InternalRemoteCache) hotrod.cacheManager.getCache(name);
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy