User::loadFromId() will look up the user in the database or in memcached -- but
it does not allow for the possibility that the record has already been
retrieved. On a typical page request on the Wikimedia cluster, this causes over
a dozen duplicate memcached lookups for the user record.
Bug: T128157
Change-Id: Iec1504700ab566ca89d0ef868d495238b151034a
}
$cache = ObjectCache::getMainWANInstance();
- $data = $cache->get( $this->getCacheKey( $cache ) );
- if ( !is_array( $data ) || $data['mVersion'] < self::VERSION ) {
- // Object is expired
- return false;
- }
+ $key = $this->getCacheKey( $cache );
+ $processCache = ObjectCache::getLocalServerInstance( 'hash' );
+ $data = $processCache->get( $key );
+ if ( !is_array( $data ) ) {
+ $data = $cache->get( $key );
+ if ( !is_array( $data ) || $data['mVersion'] < self::VERSION ) {
+ // Object is expired
+ return false;
+ }
+ $processCache->set( $key, $data );
+ }
wfDebug( "User: got user {$this->mId} from cache\n" );
// Restore from cache