Storage: Use a more descriptive WAN cache keyclass in 'SqlBlobStore'
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 14 Sep 2019 01:23:36 +0000 (02:23 +0100)
committerKrinkle <krinklemail@gmail.com>
Sat, 14 Sep 2019 02:22:01 +0000 (02:22 +0000)
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
tests/phpunit/includes/RevisionTest.php

index 8c011df..bcbc9e8 100644 (file)
@@ -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
                );
index ed4a27f..249fa78 100644 (file)
@@ -850,8 +850,7 @@ class RevisionTest extends MediaWikiTestCase {
                );
 
                $cacheKey = $cache->makeGlobalKey(
-                       'BlobStore',
-                       'address',
+                       'SqlBlobStore-blob',
                        $lb->getLocalDomainID(),
                        'tt:7777'
                );