From fe3c4189254d7b25df8473ded652520520c39192 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 14 Sep 2019 02:23:36 +0100 Subject: [PATCH] Storage: Use a more descriptive WAN cache keyclass in 'SqlBlobStore' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- includes/Storage/SqlBlobStore.php | 15 +++++++-------- tests/phpunit/includes/RevisionTest.php | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) 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' ); -- 2.20.1