jenkins-bot has submitted this change and it was merged.
Change subject: Non-micro optimization for the main page - cache projects
......................................................................
Non-micro optimization for the main page - cache projects
At dev.translatewiki.net this saves 150 ms from the median
page serving time:
Before:
min mean[+/-sd] median max
Connect: 5 6 1.2 6 9
Processing: 377 404 23.3 400 509
Waiting: 377 404 23.4 400 509
Total: 382 410 23.4 406 514
After:
min mean[+/-sd] median max
Connect: 5 6 0.9 6 8
Processing: 216 248 22.4 241 306
Waiting: 216 248 22.4 241 306
Total: 223 254 22.5 249 311
Change-Id: I3e73315241bc7f060fe27df9b4a6c0e06b1b2069
---
M ProjectHandler.php
1 file changed, 13 insertions(+), 1 deletion(-)
Approvals:
Siebrand: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ProjectHandler.php b/ProjectHandler.php
index a08810c..520adde 100644
--- a/ProjectHandler.php
+++ b/ProjectHandler.php
@@ -10,6 +10,17 @@
class ProjectHandler {
public function getProjects() {
$projects = array();
+
+ $cache = wfGetCache( CACHE_ANYTHING );
+ $cacheKey = wfMemckey( __METHOD__ );
+ $ids = $cache->get( $cacheKey );
+ if ( is_array( $ids ) ) {
+ $projects = array_map( 'MessageGroups::getGroup', $ids
);
+ $projects = array_filter( $projects );
+ return $projects;
+ }
+
+ // Not cached, find them
$groups = MessageGroups::getGroupStructure();
foreach ( $groups as $mixed ) {
@@ -20,10 +31,11 @@
}
if ( $group->getIcon() !== null ) {
- $projects[] = $group;
+ $projects[$group->getId()] = $group;
}
}
+ $cache->set( $cacheKey, array_keys( $projects ), 60 * 60 * 24 );
return $projects;
}
--
To view, visit https://gerrit.wikimedia.org/r/118815
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3e73315241bc7f060fe27df9b4a6c0e06b1b2069
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TwnMainPage
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits