From 670687fae0b9d1d26cf0a0bdb146fb6f08440bfa Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 8 Jul 2019 12:12:16 -0700 Subject: [PATCH] objectcache: add IStoreKeyEncoder interface for key generation helper methods If a key is stored in both BagOStuff and WANObjectCache, it useful to have one common method for generating the cache and storage keys. Change-Id: I8b77651746a55e8a98a79db298226e334d15a494 --- autoload.php | 1 + includes/libs/objectcache/BagOStuff.php | 2 +- .../libs/objectcache/IStoreKeyEncoder.php | 27 +++++++++++++++++++ includes/libs/objectcache/WANObjectCache.php | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 includes/libs/objectcache/IStoreKeyEncoder.php diff --git a/autoload.php b/autoload.php index 5eadf79b80..218c244a53 100644 --- a/autoload.php +++ b/autoload.php @@ -659,6 +659,7 @@ $wgAutoloadLocalClasses = [ 'IP' => __DIR__ . '/includes/libs/IP.php', 'IPTC' => __DIR__ . '/includes/media/IPTC.php', 'IRCColourfulRCFeedFormatter' => __DIR__ . '/includes/rcfeed/IRCColourfulRCFeedFormatter.php', + 'IStoreKeyEncoder' => __DIR__ . '/includes/libs/objectcache/IStoreKeyEncoder.php', 'IcuCollation' => __DIR__ . '/includes/collation/IcuCollation.php', 'IdentityCollation' => __DIR__ . '/includes/collation/IdentityCollation.php', 'ImageBuilder' => __DIR__ . '/maintenance/rebuildImages.php', diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 7759947ee0..d7137d5679 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -61,7 +61,7 @@ use Wikimedia\WaitConditionLoop; * * @ingroup Cache */ -abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { +abstract class BagOStuff implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInterface { /** @var array[] Lock tracking */ protected $locks = []; /** @var int ERR_* class constant */ diff --git a/includes/libs/objectcache/IStoreKeyEncoder.php b/includes/libs/objectcache/IStoreKeyEncoder.php new file mode 100644 index 0000000000..da0686ea0c --- /dev/null +++ b/includes/libs/objectcache/IStoreKeyEncoder.php @@ -0,0 +1,27 @@ +