Package com.oracle.content.sdk
Class CacheSettings
java.lang.Object
com.oracle.content.sdk.CacheSettings
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Expiration time class to tweak the expiration values for cache. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCacheSettings
(File cacheDir) Construct cache config specifying a cache dir to enable it. -
Method Summary
Modifier and TypeMethodDescriptionenableOfflineCache
(boolean enable) By default, if the cache is enabled the offline cache is enabled.boolean
Is the cache enabled?boolean
Is offline cache enabled?setAssetCacheDir
(File dir) Optionally override the cache folder to use for assets.setAssetCacheSize
(long size) Override the maximum asset cache size.void
setCacheExpiration
(CacheSettings.Expiration expiration) Set the general cache expiration valuesetHttpCacheSize
(long size) Set the cache size in bytes.void
setOfflineCacheExpiration
(CacheSettings.Expiration expiration) Set the offline cache expiration value
-
Field Details
-
MB
public static final long MB- See Also:
-
-
Constructor Details
-
CacheSettings
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
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
Set the cache size in bytes.- Parameters:
size
- cache size in bytes- Returns:
- this
-
setAssetCacheSize
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
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
Set the general cache expiration value- Parameters:
expiration
- general cache expiration
-
setOfflineCacheExpiration
Set the offline cache expiration value- Parameters:
expiration
- general cache expiration
-