Package com.transifex.txnative.cache
Class TxStandardCache
- java.lang.Object
-
- com.transifex.txnative.cache.TxStandardCache
-
public class TxStandardCache extends Object
The standard cache configuration that the TxNative SDK is initialized with, if no other cache is provided.TxStandardCache is backed by a
TxMemoryCache
which is initialized with existing translation files from the app's Assets folder and the app's cache directory in this specific order. When the cache is updated (when new translations become available after callingTxNative.fetchTranslations(String)
), TxStandardCache stores the new translations in the app's cache directory. The in-memory translations are not affected by the update though. A new instance of TxStandardCache has to be created (after an app restart by default) to read the new translations saved in the app's cache directory
-
-
Method Detail
-
getCache
public static TxCache getCache(@NonNull Context context, @Nullable Integer updatePolicy, @Nullable File cachedTranslationsDirectory)
Creates a cache with the configuration explained inTxStandardCache
.- Parameters:
context
- The app's context.updatePolicy
- The update policy to be used when initializing the internal memory cache with the stored contents from disk. If set tonull
,REPLACE_ALL
is used.cachedTranslationsDirectory
- The directory where the cache will store new translations when available and read translations from when initialized. If set tonull
it uses a "txnative" folder in the app's internal cache directory.- Returns:
- A TxCache instance.
-
-