Wctaiwan has uploaded a new change for review.
https://gerrit.wikimedia.org/r/161887
Change subject: Cache non-category targets
......................................................................
Cache non-category targets
Category targets are not cached because the cache key scheme doesn't
work for them and parser function targets are the expensive ones.
Change-Id: Id74e240e898e2fa5c027ebd438b149a67db6a19b
---
M includes/MassMessageTargets.php
1 file changed, 21 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage
refs/changes/87/161887/1
diff --git a/includes/MassMessageTargets.php b/includes/MassMessageTargets.php
index cc46bcc..42b341f 100644
--- a/includes/MassMessageTargets.php
+++ b/includes/MassMessageTargets.php
@@ -14,13 +14,29 @@
* wiki: The ID of the wiki (wfWikiID() for the local wiki)
* site: The hostname and port (if exists) of the wiki
*
+ * Normalized targets are briefly cached because it can be expensive to
parse PF targets on both
+ * preview and save in SpecialMassMessage.
+ *
* @param Title $spamlist
* @param $normalize Whether to normalize and deduplicate the targets
* @return array|null
*/
public static function getTargets( Title $spamlist, $normalize = true
) {
+ global $wgMemc;
+
if ( !$spamlist->exists() && !$spamlist->inNamespace(
NS_CATEGORY ) ) {
return null;
+ }
+
+ // Try to lookup cached targets
+ $cacheKey = null;
+ if ( !$spamlist->inNamespace( NS_CATEGORY ) ) {
+ $cacheKey = wfMemcKey( 'massmessage', 'targets',
$spamlist->getLatestRevId(),
+ $spamlist->getTouched() );
+ $cacheTargets = $wgMemc->get( $cacheKey );
+ if ( $cacheTargets !== false ) {
+ return $cacheTargets;
+ }
}
if ( $spamlist->inNamespace( NS_CATEGORY ) ) {
@@ -38,7 +54,11 @@
}
if ( $normalize ) {
- return self::normalizeTargets( $targets );
+ $normalized = self::normalizeTargets( $targets );
+ if ( $cacheKey ) { // $spamlist is not a category
+ $wgMemc->set( $cacheKey, $normalized, 60 * 20 );
+ }
+ return $normalized;
} else {
return $targets;
}
--
To view, visit https://gerrit.wikimedia.org/r/161887
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id74e240e898e2fa5c027ebd438b149a67db6a19b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Wctaiwan <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits