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 calling TxNative.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

  • Constructor Details

    • TxStandardCache

      public TxStandardCache()
  • Method Details

    • getCache

      public static TxCache getCache(@NonNull Context context, @Nullable Integer updatePolicy, @Nullable File cachedTranslationsDirectory)
      Creates a cache with the configuration explained in TxStandardCache.
      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 to null, REPLACE_ALL is used.
      cachedTranslationsDirectory - The directory where the cache will store new translations when available and read translations from when initialized. If set to null it uses a "txnative" folder in the app's internal cache directory.
      Returns:
      A TxCache instance.