r104682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104681‎ | r104682 | r104683 >
Date:14:41, 30 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
performace fix now it doesn't cache in case that timestamp is expired
to prevent extra writes to db in case that it would cache information
that db needs to be updated.

probably this check could be wrapped to function because it's there
more than 3 times now.
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php
@@ -83,14 +83,16 @@
8484 } else {
8585 // checking only if we need to do write or not
8686 $result = self::getCache( $user->getName(), ONLINESTATUSBAR_DELAYED_CACHE );
 87+ $w_time = OnlineStatusBar::getTimeoutDate( ONLINESTATUSBAR_CK_DELAYED );
8788 if ( $result == '' ) {
8889 $dbr = wfGetDB( DB_SLAVE );
8990 $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName() ),
9091 __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) );
9192 // cache it
92 - self::setCache( $user->getName(), $result, ONLINESTATUSBAR_DELAYED_CACHE );
 93+ if ( $result !== false && $result > wfTimestamp( TS_MW, $w_time ) ) {
 94+ self::setCache( $user->getName(), $result, ONLINESTATUSBAR_DELAYED_CACHE );
 95+ }
9396 }
94 - $w_time = OnlineStatusBar::getTimeoutDate( ONLINESTATUSBAR_CK_DELAYED );
9597 }
9698
9799 if ( $result === false ) {

Status & tagging log