[PLUGIN][ProfileColor] Cache results

This commit is contained in:
Hugo Sales 2021-12-12 17:02:55 +00:00
parent 3ba7e1804b
commit ff38efd5f1
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -22,6 +22,7 @@ declare(strict_types = 1);
namespace Plugin\ProfileColor; namespace Plugin\ProfileColor;
use App\Core\Cache;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use App\Core\Modules\Plugin; use App\Core\Modules\Plugin;
@ -84,7 +85,7 @@ class ProfileColor extends Plugin
$actor_id = $actor->getId(); $actor_id = $actor->getId();
try { try {
$profile_color_tab = DB::findOneBy('profile_color', ['actor_id' => $actor_id]); $profile_color_tab = Cache::get("profile-color-{$actor_id}", DB::findOneBy('profile_color', ['actor_id' => $actor_id]));
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
return Event::next; return Event::next;
} }