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

org.infinispan.client.hotrod.near.BoundedConcurrentMapNearCache Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.client.hotrod.near;

import java.util.concurrent.ConcurrentMap;

import org.infinispan.client.hotrod.VersionedValue;
import org.infinispan.client.hotrod.configuration.NearCacheConfiguration;
import org.infinispan.commons.util.CollectionFactory;

/**
 * Near cache based on {@link BoundedConcurrentMapNearCache}
 *
 * @since 7.2
 */
final class BoundedConcurrentMapNearCache implements NearCache {

   private final ConcurrentMap> cache;

   private BoundedConcurrentMapNearCache(ConcurrentMap> cache) {
      this.cache = cache;
   }

   public static  NearCache create(final NearCacheConfiguration config) {
      return new BoundedConcurrentMapNearCache(
         CollectionFactory.>makeBoundedConcurrentMap(config.maxEntries()));
   }

   @Override
   public void put(K key, VersionedValue value) {
      cache.put(key, value);
   }

   @Override
   public void putIfAbsent(K key, VersionedValue value) {
      cache.putIfAbsent(key, value);
   }

   @Override
   public void remove(K key) {
      cache.remove(key);
   }

   @Override
   public VersionedValue get(K key) {
      return cache.get(key);
   }

   @Override
   public void clear() {
      cache.clear();
   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy