TranslationCache

The TranslationCache class is responsible for caching translations and providing access to cached translations in a thread-safe manner.

Types

Link copied to clipboard

Provides an access to JAR file systems.

Properties

Link copied to clipboard

Returns the list of available languages.

Functions

Link copied to clipboard
fun clear()

Clears the cache.

Link copied to clipboard
fun contains(name: String): Boolean

Checks if the given name exists in the cache.

Link copied to clipboard
fun get(languageCode: String, messageKey: String, placeholders: Map<String, Any?> = emptyMap()): Translation?

Retrieves the translation for the given language code and message key.

Link copied to clipboard

Retrieves all translations from the cache.

Link copied to clipboard

Retrieves translations for a given message key.

Link copied to clipboard
fun loadAll()

Loads all translations from the database and updates the cache. This method acquires a write lock to ensure thread safety when updating the cache. After the cache is updated, it logs the number of translations loaded and the time taken to load them.

Link copied to clipboard
fun put(name: String, translation: List<Translation>)

Adds a translation to the cache for a given name.

Link copied to clipboard
fun remove(name: String)

Removes the specified name from the cache.