Class CacheWorkArounds<K,​V>


  • public class CacheWorkArounds<K,​V>
    extends Object
    Infinispan cache work arounds.
    • Fix around invalidation bug, to force cache load before putIfAbsent, replace, delete operations. See tracking Connect2id server issue https://bitbucket.org/connect2id/server/issues/239/race-condition-in-cacheremove-in
    • Enforcing zero cache size for "stateless mode" to enable Infinispan to be run in local mode with no in-memory store, using the configured stores instead.
    • Constructor Detail

      • CacheWorkArounds

        public CacheWorkArounds​(org.infinispan.Cache<K,​V> infinispanCache)
        Creates a new cache work arounds instance.
        Parameters:
        infinispanCache - The Infinispan cache.
      • CacheWorkArounds

        public CacheWorkArounds​(org.infinispan.Cache<K,​V> infinispanCache,
                                org.apache.logging.log4j.Logger log)
        Creates a new cache work arounds instance.
        Parameters:
        infinispanCache - The Infinispan cache.
        log - Optional logger for the detection, null if not specified.
    • Method Detail

      • detectInvalidationMode

        public static boolean detectInvalidationMode​(org.infinispan.Cache<?,​?> cache)
        Checks if the specified cache is configured in invalidation mode.
        Parameters:
        cache - The cache to check.
        Returns:
        true if the cache is configured in invalidation mode, else false.
      • detectStatelessMode

        public static boolean detectStatelessMode​(org.infinispan.Cache<?,​?> cache)
        Checks if the specified cache is configured in "stateless mode".
        Parameters:
        cache - The cache to check.
        Returns:
        true if the cache is configured in "stateless mode", else false.
      • getMode

        public CacheWorkArounds.Mode getMode()
        Returns the special work around mode.
        Returns:
        The work around mode, null if none (implies follow regular operation).
      • isInvalidation

        public boolean isInvalidation()
        Returns true if the cache is in invalidation mode.
        Returns:
        true if the cache is in invalidation mode, else false.
      • isStateless

        public boolean isStateless()
        Returns true if the cache is in the special "stateless mode".
        Returns:
        true if the cache is in the "stateless mode", else false.
      • clearCacheIfStateless

        public void clearCacheIfStateless()
        If the cache is in the special "stateless mode" causes the underlying data container (in memory) to be cleared. Should be called before get, replace, putIfAbsent, remove and iteration operations.