diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2024-05-03 16:23:31 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2024-05-03 16:23:31 +0000 |
commit | ba7fe379d056685ed270c7355111e668d1966730 (patch) | |
tree | 73c37b0ca28a7853580d3827f94e4738905b6e27 /includes/externalstore | |
parent | 6586301a48d415c00917175c870110f1acfdae1b (diff) | |
parent | 4dbbbfa5507bba2c05100324237aceb760afe4ed (diff) | |
download | mediawikicore-ba7fe379d056685ed270c7355111e668d1966730.tar.gz mediawikicore-ba7fe379d056685ed270c7355111e668d1966730.zip |
Merge "SqlBlobStore: Directly store ES addresses in content table"
Diffstat (limited to 'includes/externalstore')
-rw-r--r-- | includes/externalstore/ExternalStoreFactory.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/includes/externalstore/ExternalStoreFactory.php b/includes/externalstore/ExternalStoreFactory.php index 68f4dacb23ff..5e3fa13ad768 100644 --- a/includes/externalstore/ExternalStoreFactory.php +++ b/includes/externalstore/ExternalStoreFactory.php @@ -20,6 +20,7 @@ class ExternalStoreFactory implements LoggerAwareInterface { private $localDomainId; /** @var LoggerInterface */ private $logger; + private $stores = []; /** * @param string[] $externalStores See $wgExternalStores @@ -72,6 +73,10 @@ class ExternalStoreFactory implements LoggerAwareInterface { * @throws ExternalStoreException When $proto is not recognized */ public function getStore( $proto, array $params = [] ) { + $cacheKey = $proto . ':' . json_encode( $params ); + if ( isset( $this->stores[$cacheKey] ) ) { + return $this->stores[$cacheKey]; + } $protoLowercase = strtolower( $proto ); // normalize if ( !$this->protocols || !in_array( $protoLowercase, $this->protocols ) ) { throw new ExternalStoreException( "Protocol '$proto' is not enabled." ); @@ -103,7 +108,8 @@ class ExternalStoreFactory implements LoggerAwareInterface { } // Any custom modules should be added to $wgAutoLoadClasses for on-demand loading - return new $class( $params ); + $this->stores[$cacheKey] = new $class( $params ); + return $this->stores[$cacheKey]; } /** |