Class CacheWorkArounds<K,V>

java.lang.Object
com.nimbusds.common.infinispan.CacheWorkArounds<K,V>

public class CacheWorkArounds<K,V> extends Object
Infinispan cache workarounds.
  • 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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The handled special modes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CacheWorkArounds(org.infinispan.Cache<K,V> infinispanCache)
    Creates a new cache workarounds instance.
    CacheWorkArounds(org.infinispan.Cache<K,V> infinispanCache, org.apache.logging.log4j.Logger log)
    Creates a new cache workarounds instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    If the cache is in the special "stateless mode" causes the underlying data container (in memory) to be cleared.
    static boolean
    detectInvalidationMode(org.infinispan.Cache<?,?> cache)
    Checks if the specified cache is configured in invalidation mode.
    static boolean
    detectStatelessMode(org.infinispan.Cache<?,?> cache)
    Checks if the specified cache is configured in "stateless mode".
    Returns the special workaround mode.
    boolean
    Returns true if the cache is in invalidation mode.
    boolean
    Returns true if the cache is in the special "stateless mode".

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CacheWorkArounds

      public CacheWorkArounds(org.infinispan.Cache<K,V> infinispanCache)
      Creates a new cache workarounds 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 workarounds instance.
      Parameters:
      infinispanCache - The Infinispan cache.
      log - Optional logger for the detection, null if not specified.
  • Method Details

    • 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

      Returns the special workaround mode.
      Returns:
      The workaround 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.