001package com.nimbusds.common.infinispan;
002
003
004import org.infinispan.Cache;
005
006
007/**
008 * Detects if a cache is configured in "zero mode", meaning the cache mode is
009 * local and entries must be fetched directly from the underlying store(s).
010 * Infinispan doesn't permit setting a cache size to zero, therefore one (1) is
011 * used to imply a "zero mode".
012 *
013 * <p>The "zero mode" is intended to facilitate deployments where Redis or
014 * some other database is intended to serve as in-memory cache / map.
015 */
016@Deprecated
017public class ZeroCacheModeDetector {
018        
019        
020        /**
021         * Checks if the specified caches are configured in "zero mode".
022         *
023         * @param caches The caches to check.
024         *
025         * @return {@code true} if the at least one of the caches is configured
026         *         in "zero mode", else {@code false}.
027         */
028        public static boolean detect(final Cache ... caches) {
029                
030                for (Cache cache: caches) {
031                        
032                        if (CacheWorkArounds.detectStatelessMode(cache)) {
033                                return true;
034                        }
035                }
036                
037                return false;
038        }
039        
040        
041        /**
042         * Prevents public instantiation.
043         */
044        private ZeroCacheModeDetector() {}
045}