Class TxProviderBasedCache

java.lang.Object
com.transifex.txnative.cache.TxDecoratorCache
com.transifex.txnative.cache.TxProviderBasedCache
All Implemented Interfaces:
TxCache

public class TxProviderBasedCache extends TxDecoratorCache
Composite class that accepts a number of translations providers and an internal cache. When initialized, the providers are used to update the internal class in the order they are added in the providers array.

Example usage:

 TxCache cache = new TxProviderBasedCache(
         new TxDiskTranslationsProvider[]{
                 new TxDiskTranslationsProvider(firstTranslationsDirectory),
                 new TxDiskTranslationsProvider(secondTranslationsDirectory)},
         new TxMemoryCache());
 
  • Constructor Details

    • TxProviderBasedCache

      public TxProviderBasedCache(@NonNull TxTranslationsProvider[] providers, @NonNull TxCache internalCache)
      Creates a provider-based cache with the given internal cache and updates it with with the contents of the given translations providers.

      The translations providers update the internal cache in the given order. If they return a null or empty LocaleData.TranslationMap they are ignored.

      The providers' content is accessed synchronously in the class's constructor.

      Parameters:
      providers - An array of translations providers.
      internalCache - The internal cache to be used.