diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-11-17 10:34:43 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-12-07 22:32:06 +0100 |
commit | 306d7829b58cc840e2e6fcb6d4dfd341da37547a (patch) | |
tree | 205686eea1ce207dcd8ed0ec0cddad668685ec93 /lib/private/L10N | |
parent | be4c061b754df917c02bf111b1a15e3c1062b4b8 (diff) | |
download | nextcloud-server-306d7829b58cc840e2e6fcb6d4dfd341da37547a.tar.gz nextcloud-server-306d7829b58cc840e2e6fcb6d4dfd341da37547a.zip |
Cache available languages locally
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/L10N')
-rw-r--r-- | lib/private/L10N/Factory.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index 7fcfab37fa6..71910873db7 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -40,6 +40,8 @@ declare(strict_types=1); namespace OC\L10N; +use OCP\ICache; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IRequest; use OCP\IUser; @@ -94,7 +96,9 @@ class Factory implements IFactory { protected $request; /** @var IUserSession */ - protected $userSession; + protected IUserSession $userSession; + + private ICache $cache; /** @var string */ protected $serverRoot; @@ -109,11 +113,13 @@ class Factory implements IFactory { IConfig $config, IRequest $request, IUserSession $userSession, + ICacheFactory $cacheFactory, $serverRoot ) { $this->config = $config; $this->request = $request; $this->userSession = $userSession; + $this->cache = $cacheFactory->createLocal('L10NFactory'); $this->serverRoot = $serverRoot; } @@ -338,6 +344,10 @@ class Factory implements IFactory { $key = 'null'; } + if ($availableLanguages = $this->cache->get($key)) { + $this->availableLanguages[$key] = $availableLanguages; + } + // also works with null as key if (!empty($this->availableLanguages[$key])) { return $this->availableLanguages[$key]; @@ -374,6 +384,7 @@ class Factory implements IFactory { } $this->availableLanguages[$key] = $available; + $this->cache->set($key, $available, 60); return $available; } |