Class CacheSettings

java.lang.Object
com.oracle.content.sdk.CacheSettings

public final class CacheSettings extends Object
The CacheSettings specifies settings for the cache behavior of the SDK The cacheDir is required to enable the cache. Here is an example of creating a CacheSettings:
   

  CacheSettings cacheSettings = new CacheSettings(context.getCacheDir());
 
If not specified, there are default values for cache size (10MB), as well as in-memory cache expiration (2 minutes) and offline cache (7 days). The offline cache will allow you to request cached SDK results even if there is no network access.
  • Field Details

  • Constructor Details

    • CacheSettings

      public CacheSettings(File cacheDir)
      Construct cache config specifying a cache dir to enable it. Both http and asset caches are enabled by default. If set to null, cache is disabled.
      Parameters:
      cacheDir - directory location to store cache
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Is the cache enabled?
      Returns:
      true if the cache is enabled
    • setAssetCacheDir

      public CacheSettings setAssetCacheDir(File dir)
      Optionally override the cache folder to use for assets. Set to null to effectively turn off cache for assets.
      Parameters:
      dir - the asset cache dir
      Returns:
      this
    • setHttpCacheSize

      public CacheSettings setHttpCacheSize(long size)
      Set the cache size in bytes.
      Parameters:
      size - cache size in bytes
      Returns:
      this
    • setAssetCacheSize

      public CacheSettings setAssetCacheSize(long size)
      Override the maximum asset cache size.
      Parameters:
      size - Size in bytes
      Returns:
      this
    • isOfflineCacheEnabled

      public boolean isOfflineCacheEnabled()
      Is offline cache enabled?
      Returns:
      true if offline cache is enabled
    • enableOfflineCache

      public CacheSettings enableOfflineCache(boolean enable)
      By default, if the cache is enabled the offline cache is enabled. Call this method with 'false' to disable just offline cache.
      Parameters:
      enable - true to enable offline cache (default) or false to disable
      Returns:
      this
    • setCacheExpiration

      public void setCacheExpiration(CacheSettings.Expiration expiration)
      Set the general cache expiration value
      Parameters:
      expiration - general cache expiration
    • setOfflineCacheExpiration

      public void setOfflineCacheExpiration(CacheSettings.Expiration expiration)
      Set the offline cache expiration value
      Parameters:
      expiration - general cache expiration