From 68c6dd1ba991857e6df04458b5020b28c581fb63 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Mon, 8 Nov 2021 15:07:29 +0000 Subject: [PATCH] [CORE][Cache] Use hashmaps to store language related items --- src/Entity/Actor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entity/Actor.php b/src/Entity/Actor.php index f9e6b0fda5..f3485579c6 100644 --- a/src/Entity/Actor.php +++ b/src/Entity/Actor.php @@ -361,14 +361,14 @@ class Actor extends Entity public function getPreferredLanguageChoices(?self $context = null): array { $id = $context?->getId() ?? $this->getId(); - return Cache::get( + return Cache::getHashMap( 'actor-' . $this->getId() . '-langs' . (!\is_null($context) ? '-' . $context->getId() : ''), fn () => array_merge( // TODO replace with F\transform ...F\map(DB::dql( 'select l from actor_language al join language l with al.language_id = l.id where al.actor_id = :id order by al.order ASC', ['id' => $id], ), fn ($l) => $l->toChoiceFormat()), - ) ?: DB::findOneBy('language', ['locale' => Common::config('site', 'language')])->toChoiceFormat(), + ) ?: Cache::getHashMapKey('languages', Common::config('site', 'language'))->toChoiceFormat(), ); }