Package com.groiss.ds

Class Caches

java.lang.Object
com.groiss.ds.Caches

public class Caches extends Object
This is a utility class to construct clustered caches which propagate changes in the cluster.
  • Method Details

    • getClusteredCache

      public static <K, V> Map<K,V> getClusteredCache(String name)
      Constructs a clustered Cache.

      The operations clear() and remove(K) are propagated within the cluster. The operation put(K,V) is propagated within the cluster if the result of put (the previous value) is not null. Please note that a local put operation is propagated exactly like a remove operation (the caches on the remote node will remove the entry).

      In a non-clustered environment, there is virtually no overhead compared to a local map.

      Type Parameters:
      K - the type of the keys
      V - the type of the values
      Parameters:
      name - the name of the cache
      Returns:
      a clustered cache. throws an ApplicationException, when a cache with this name already exists
    • getClusteredCache

      public static <K, V> Map<K,V> getClusteredCache(String name, int capacity, long lifespan)
      Constructs a clustered Cache.

      The operations clear() and remove(K) are propagated within the cluster. The operation put(K,V) is propagated within the cluster if the result of put (the previous value) is not null. Please note that a local put operation is propagated exactly like a remove operation (the caches on the remote node will remove the entry).

      In a non-clustered environment, there is virtually no overhead compared to a local map.

      Type Parameters:
      K - the type of the keys
      V - the type of the values
      Parameters:
      name - the name of the cache
      capacity - the maximum count of elements in the cache. if the value is less than 1, the cache has unlimited capacity
      lifespan - the maximum amount of milliseconds an cache entry is 'valid'. if the value is less than 1, elements have no lifespan restriction
      Returns:
      a clustered cache. throws an ApplicationException, when a cache with this name already exists