src/I18n/DbMessageSource.php
protected function loadMessages($category, $language)
    {
        if ($this->enableCaching) {
            $cacheKey = [
                __CLASS__,
                $category,
                $language,
            ];
            return $this->cache
                ->get($cacheKey)
                ->then(function($data) {
                    return $data !== null ? $data : Reaction\Promise\reject(null);
                })->otherwise(function() use ($category, $language, $cacheKey) {
                    $messages = [];
                    return $this->loadMessagesFromDb($category, $language)
                        ->then(function($messagesDb) use (&$messages, $cacheKey) {
                            $messages = $messagesDb;
                            return $this->cache->set($cacheKey, $messagesDb, $this->cachingDuration);
                        })->then(function() use (&$messages) {
                            return $messages;
                        });
                });
        }

        return $this->loadMessagesFromDb($category, $language);
    }
protected function loadMessages($category, $language)
    {
        if ($this->enableCaching) {
            $cacheKey = [
                __CLASS__,
                $category,
                $language,
            ];
            return $this->cache
                ->get($cacheKey)
                ->then(function($data) {
                    return $data !== null ? $data : Reaction\Promise\reject(null);
                })->otherwise(function() use ($category, $language, $cacheKey) {
                    $messages = [];
                    return $this->loadMessagesFromDb($category, $language)
                        ->then(function($messagesDb) use (&$messages, $cacheKey) {
                            $messages = $messagesDb;
                            return $this->cache->set($cacheKey, $messagesDb, $this->cachingDuration);
                        })->then(function() use (&$messages) {
                            return $messages;
                        });
                });
        }

        return $this->loadMessagesFromDb($category, $language);
    }
Loads the message translation for the specified language and category.
If translation for specific locale code such as `en-US` isn't found it
tries more generic `en`.

@param string $category the message category
@param string $language the target language
@return ExtendedPromiseInterface array the loaded messages. The keys are original messages, and the values
are translated messages.