aboutsummaryrefslogtreecommitdiffstats
path: root/includes/externalstore
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2024-05-03 16:23:31 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2024-05-03 16:23:31 +0000
commitba7fe379d056685ed270c7355111e668d1966730 (patch)
tree73c37b0ca28a7853580d3827f94e4738905b6e27 /includes/externalstore
parent6586301a48d415c00917175c870110f1acfdae1b (diff)
parent4dbbbfa5507bba2c05100324237aceb760afe4ed (diff)
downloadmediawikicore-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.php8
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];
}
/**