From 337c02bd801eeac2b40a86c281e8ee9f6cf2f23c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 8 Feb 2019 20:12:07 -0500 Subject: [PATCH] Cache config adapter connection status to reduce number of calls to DBA::isConnected() --- src/Core/Config/AbstractDbaConfigAdapter.php | 5 ++++- src/Core/Config/JITConfigAdapter.php | 1 + src/Core/Config/PreloadConfigAdapter.php | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Core/Config/AbstractDbaConfigAdapter.php b/src/Core/Config/AbstractDbaConfigAdapter.php index f7fd701b00..c2e8bda5d5 100644 --- a/src/Core/Config/AbstractDbaConfigAdapter.php +++ b/src/Core/Config/AbstractDbaConfigAdapter.php @@ -6,8 +6,11 @@ use Friendica\Database\DBA; abstract class AbstractDbaConfigAdapter { + /** @var bool */ + protected $connected = true; + public function isConnected() { - return DBA::connected(); + return $this->connected; } } diff --git a/src/Core/Config/JITConfigAdapter.php b/src/Core/Config/JITConfigAdapter.php index 76476be3aa..ecd88bb3d3 100644 --- a/src/Core/Config/JITConfigAdapter.php +++ b/src/Core/Config/JITConfigAdapter.php @@ -26,6 +26,7 @@ class JITConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAdapte public function __construct(IConfigCache $configCache) { $this->configCache = $configCache; + $this->connected = DBA::connected(); } /** diff --git a/src/Core/Config/PreloadConfigAdapter.php b/src/Core/Config/PreloadConfigAdapter.php index 2fe3d4cdad..96331e7a2c 100644 --- a/src/Core/Config/PreloadConfigAdapter.php +++ b/src/Core/Config/PreloadConfigAdapter.php @@ -27,6 +27,7 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd public function __construct(IConfigCache $configCache) { $this->configCache = $configCache; + $this->connected = DBA::connected(); $this->load(); }