Package com.nimbusds.common.infinispan
Class CacheWorkArounds<K,V>
- java.lang.Object
-
- com.nimbusds.common.infinispan.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CacheWorkArounds.Mode
The handled special modes.
-
Constructor Summary
Constructors Constructor Description CacheWorkArounds(org.infinispan.Cache<K,V> infinispanCache)
Creates a new cache work arounds instance.CacheWorkArounds(org.infinispan.Cache<K,V> infinispanCache, org.apache.logging.log4j.Logger log)
Creates a new cache work arounds instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCacheIfStateless()
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".CacheWorkArounds.Mode
getMode()
Returns the special work around mode.boolean
isInvalidation()
Returnstrue
if the cache is in invalidation mode.boolean
isStateless()
Returnstrue
if the cache is in the special "stateless mode".
-
-
-
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, elsefalse
.
-
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", elsefalse
.
-
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()
Returnstrue
if the cache is in invalidation mode.- Returns:
true
if the cache is in invalidation mode, elsefalse
.
-
isStateless
public boolean isStateless()
Returnstrue
if the cache is in the special "stateless mode".- Returns:
true
if the cache is in the "stateless mode", elsefalse
.
-
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.
-
-