Class CacheService


  • public class CacheService
    extends java.lang.Object
    • Field Detail

      • CACHE_NAME

        @Deprecated
        public static final java.lang.String CACHE_NAME
        Deprecated.
        Please see ClientConstants.CACHE_NAME.toString()
      • CACHE_NAME_SERVERS_AUTO

        @Deprecated
        public static final java.lang.String CACHE_NAME_SERVERS_AUTO
        Deprecated.
        Please see ClientConstants.CACHE_NAME_SERVERS_AUTO.toString()
      • CACHE_NAME_SERVERS_MANUAL

        @Deprecated
        public static final java.lang.String CACHE_NAME_SERVERS_MANUAL
        Deprecated.
        Please see ClientConstants.CACHE_NAME_SERVERS_MANUAL.toString()
    • Constructor Detail

      • CacheService

        public CacheService​(CacheProvider cachePropsProvider)
    • Method Detail

      • getInternalFileCacheLifetime

        public int getInternalFileCacheLifetime()
        Returns the internal file cache lifetime
        Returns:
        serverRankingLifetime
      • setInternalFileCacheLifetime

        public void setInternalFileCacheLifetime​(int internalFileCacheLifetime)
        Sets the internal file cache lifetime
        Parameters:
        internalFileCacheLifetime -
      • getCacheProvider

        public CacheProvider getCacheProvider()
        Gets the cache Provider
        Returns:
        cachePropsProvider
      • getUseCache

        public boolean getUseCache()
        Is device data being cached by the API or not.
        Returns:
        true(default) = data is being cached.
      • setUseCache

        public void setUseCache​(boolean useCache)
        Setter to cache or not to cache device data.
        Parameters:
        useCache - true = cache data after getting device data from DeviceAtlas cloud
      • clearCache

        public void clearCache()
        Clear all cached data.
      • shutdown

        public void shutdown()
        This should be called when shutting down your application. It asks the cache manager to shutdown the cache and write the cache to disk. See http://ehcache.org/documentation/code-samples#shutdown-the-cachemanager
      • getCachedServerList

        public EndPoint[] getCachedServerList​(java.lang.String cacheKey)
                                       throws CacheException
        Get cached server list. For debugging cache contents.
        Parameters:
        cacheKey - cache key Client.CACHE_NAME_SERVERS_AUTO or Client.CACHE_NAME_SERVERS_MANUAL
        Returns:
        array of EndPoint objects or null if cache is empty
        Throws:
        CacheException
      • convertServerMapListToServerList

        public EndPoint[] convertServerMapListToServerList​(java.util.List<java.util.Map> listOfServerMaps)
        Convert a list of (server-data HashMaps) to an Array of EndPoint objects ehcache stores (server-data HashMaps)
      • setServerCache

        public void setServerCache​(EndPoint[] endPoints,
                                   boolean isManual)
                            throws CacheException
        Write server list to cache. Depending on the key auto ranked server list or manual ranking fail-over server list will be set
        Throws:
        CacheException
      • setDaHeaderCache

        public void setDaHeaderCache​(java.lang.String daHeaders)
                              throws CacheException
        Set the DeviceAtlas Response Headers
        Parameters:
        daHeaders -
        Throws:
        CacheException
      • getDaHeaderCache

        public java.lang.String getDaHeaderCache()
                                          throws CacheException
        Get an list of the DeviceAtlas Response Headers
        Returns:
        daHeaders[]
        Throws:
        CacheException
      • getCacheServersAutoRanking

        public java.util.List<java.util.Map> getCacheServersAutoRanking()
                                                                 throws CacheException
        Returns the list of auto ranked servers
        Returns:
        List
        Throws:
        CacheException
      • getCacheServersManualRanking

        public java.util.List<java.util.Map> getCacheServersManualRanking()
                                                                   throws CacheException
        Returns the list of manual ranked servers
        Returns:
        List
        Throws:
        CacheException