use MWException;
use WANObjectCache;
use Wikimedia\Assert\Assert;
-use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\LoadBalancer;
/**
* @param LoadBalancer $dbLoadBalancer A load balancer for acquiring database connections
- * @param WANObjectCache $cache A cache manager for caching blobs
+ * @param WANObjectCache $cache A cache manager for caching blobs. This can be the local
+ * wiki's default instance even if $wikiId refers to a different wiki, since
+ * makeGlobalKey() is used to constructed a key that allows cached blobs from the
+ * same database to be re-used between wikis. For example, enwiki and frwiki will
+ * use the same cache keys for blobs from the wikidatawiki database, regardless of
+ * the cache's default key space.
* @param bool|string $wikiId The ID of the target wiki database. Use false for the local wiki.
*/
public function __construct(
$this->getCacheKey( $blobAddress ),
$this->getCacheTTL(),
function ( $unused, &$ttl, &$setOpts ) use ( $blobAddress, $queryFlags ) {
- list( $index ) = DBAccessObjectUtils::getDBOptions( $queryFlags );
- $setOpts += Database::getCacheSetOptions( $this->getDBConnection( $index ) );
-
+ // Ignore $setOpts; blobs are immutable and negatives are not cached
return $this->fetchBlob( $blobAddress, $queryFlags );
},
[ 'pcGroup' => self::TEXT_CACHE_GROUP, 'pcTTL' => IExpiringStore::TTL_PROC_LONG ]
$this->getCacheKey( $cacheKey ),
$this->getCacheTTL(),
function () use ( $url, $flags ) {
- // No negative caching per BlobStore::getBlob()
+ // Ignore $setOpts; blobs are immutable and negatives are not cached
$blob = ExternalStore::fetchFromURL( $url, [ 'wiki' => $this->wikiId ] );
return $blob === false ? false : $this->decompressData( $blob, $flags );
/**
* Splits a blob address into three parts: the schema, the ID, and parameters/flags.
*
+ * @since 1.33
+ *
* @param string $address
*
* @throws InvalidArgumentException
* @return array [ $schema, $id, $parameters ], with $parameters being an assoc array.
*/
- private static function splitBlobAddress( $address ) {
+ public static function splitBlobAddress( $address ) {
if ( !preg_match( '/^(\w+):(\w+)(\?(.*))?$/', $address, $m ) ) {
throw new InvalidArgumentException( "Bad blob address: $address" );
}