r104229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104228‎ | r104229 | r104230 >
Date:10:38, 25 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
Another performance tweak, now cache that we trimmed records, so that it's not called so frequently
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php
@@ -31,11 +31,14 @@
3232 * @param $values
3333 * @return true
3434 */
35 - public static function setCache( $user, $values, $type ) {
 35+ public static function setCache( $user, $values, $type, $time = null ) {
3636 global $wgOnlineStatusBarWriteTime, $wgMemc;
3737 // get a key
3838 $cache_key = self::getCacheKey( $user, $type );
39 - $wgMemc->set( $cache_key, $values, $wgOnlineStatusBarWriteTime );
 39+ if ( $time === null ) {
 40+ $time = $wgOnlineStatusBarWriteTime );
 41+ }
 42+ $wgMemc->set( $cache_key, $values, $time );
4043 return true;
4144 }
4245
@@ -188,6 +191,9 @@
189192 if ( !$wgOnlineStatusBarAutoDelete ) {
190193 return 0;
191194 }
 195+ if ( self::getCache( 'null', 'delete' ) == 'true' ) {
 196+ return 0;
 197+ }
192198 $dbw = wfGetDB( DB_MASTER );
193199 $t_time = OnlineStatusBar::getTimeoutDate();
194200 $result = $dbw->selectField( 'online_status', 'timestamp', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $t_time ) ) ),
@@ -200,6 +206,7 @@
201207 // calculate time and convert it back to mediawiki format
202208 $time = OnlineStatusBar::getTimeoutDate();
203209 $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ );
 210+ self::setCache( 'null', 'true', 'delete', 3600 ); // remember we deleted it for 1 hour so that we avoid calling this too many times
204211 return 0;
205212 }
206213 }
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -17,7 +17,7 @@
1818 $wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array(
1919 'path' => __FILE__,
2020 'name' => 'Online status bar',
21 - 'version' => '1.0.3',
 21+ 'version' => '1.0.4',
2222 'author' => array( 'Petr Bena' ),
2323 'descriptionmsg' => 'onlinestatusbar-desc',
2424 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar',

Follow-up revisions

RevisionCommit summaryAuthorDate
r104230typo fix, r104229petrb10:42, 25 November 2011

Status & tagging log