TXCacheUpdatePolicy

@objc
public enum TXCacheUpdatePolicy : Int

Update policy that specifies the way that the internal cache is updated with new translations.

You can find an easy to understand table containing a number of cases and how each policy updates the cache below:

 | Key || Cache | New  || Replace All   | Update using Translated        |
 |-----||-------|------||---------------|--------------------------------|
 | a   || "a"   | -    || -             | "a"                            |
 | b   || "b"   | "B"  || "B"           | "B"                            |
 | c   || "c"   | ""   || ""            | "c"                            |
 | d   || ""    | -    || -             | ""                             |
 | e   || ""    | "E"  || "E"           | "E"                            |
 | f   || -     | "F"  || "F"           | "F"                            |
 | g   || -     | ""   || ""            | -                              |

Here’s an example on how to read the table above:

  • Given a string with key="c"
  • and a cache that has "c" as the stored value for this key ("c" -> "c")
  • if an empty translation arrives for this string ("")
    • if policy is .replaceAll, then the cache will be updated so that ("c" -> "")
    • in contrast to that, if policy is .updateUsingTranslated, then the cache will stay as is ("c" -> "c"), because the new translation is empty.

A "-" value means that the respective key does not exist. For example:

  • Given a string with key="f"
  • and a cache that has no entry with "f" as a key
  • if a translation arrives for this string ("f" -> "F")
    • if policy is .replaceAll, then the cache will be updated by adding a new entry so that ("f" -> "F")
    • if policy is .updateUsingTranslated, then the same will happen, since the new translation is not empty
  • Discards the existing cache entries completely and populates the cache with the new entries, even if they contain empty translations.

    Declaration

    Swift

    case replaceAll
  • Updates the existing cache with the new entries that have a non-empty translation, ignoring the rest.

    Declaration

    Swift

    case updateUsingTranslated