From: Timo Tijhof Date: Sat, 14 Sep 2019 01:23:36 +0000 (+0100) Subject: Storage: Use a more descriptive WAN cache keyclass in 'SqlBlobStore' X-Git-Tag: 1.34.0-rc.0~218^2 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=fe3c4189254d7b25df8473ded652520520c39192;p=lhc%2Fweb%2Fwiklou.git Storage: Use a more descriptive WAN cache keyclass in 'SqlBlobStore' In order to make statistics from WANObjectCache more useful, each kind of key should generally have a unique first make*Key component. This usually corresponds 1:1 to a call to make*Key, unless the same key format is duplicated in muliple places. In this case, change ('BlobStore', 'address', …, …) to ('SqlBlobStore-blob', …, …). Bug: T197849 Change-Id: Iba3ae1bf947d6f56c72df2cf3f2160d458d38c66 --- diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php index 8c011dffa7..bcbc9e8a8f 100644 --- a/includes/Storage/SqlBlobStore.php +++ b/includes/Storage/SqlBlobStore.php @@ -103,10 +103,10 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { * @param ExternalStoreAccess $extStoreAccess Access layer for external storage * @param WANObjectCache $cache A cache manager for caching blobs. This can be the local * wiki's default instance even if $dbDomain 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. + * makeGlobalKey() is used to construct a key that allows cached blobs from the + * same database to be re-used between wikis. For example, wiki A and wiki B will + * use the same cache keys for blobs fetched from wiki C, regardless of the + * wiki-specific default key space. * @param bool|string $dbDomain The ID of the target wiki database. Use false for the local wiki. */ public function __construct( @@ -449,16 +449,15 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { * Get a cache key for a given Blob address. * * The cache key is constructed in a way 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. + * to be re-used between wikis. For example, wiki A and wiki B will use the same cache keys + * for blobs fetched from wiki C. * * @param string $blobAddress * @return string */ private function getCacheKey( $blobAddress ) { return $this->cache->makeGlobalKey( - 'BlobStore', - 'address', + 'SqlBlobStore-blob', $this->dbLoadBalancer->resolveDomainID( $this->dbDomain ), $blobAddress ); diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index ed4a27f42a..249fa78dab 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -850,8 +850,7 @@ class RevisionTest extends MediaWikiTestCase { ); $cacheKey = $cache->makeGlobalKey( - 'BlobStore', - 'address', + 'SqlBlobStore-blob', $lb->getLocalDomainID(), 'tt:7777' );