mOptions = array(); } else { $this->mOptions = array( 'FOR UPDATE' ); } $this->mDb = wfGetDB( DB_MASTER ); } /** * Invalidate the cache of a list of pages from a single namespace * * @param $namespace Integer * @param $dbkeys Array */ public function invalidatePages( $namespace, $dbkeys ) { if ( !count( $dbkeys ) ) { return; } /** * Determine which pages need to be updated * This is necessary to prevent the job queue from smashing the DB with * large numbers of concurrent invalidations of the same page */ $now = $this->mDb->timestamp(); $ids = array(); $res = $this->mDb->select( 'page', array( 'page_id' ), array( 'page_namespace' => $namespace, 'page_title IN (' . $this->mDb->makeList( $dbkeys ) . ')', 'page_touched < ' . $this->mDb->addQuotes( $now ) ), __METHOD__ ); foreach ( $res as $row ) { $ids[] = $row->page_id; } if ( !count( $ids ) ) { return; } /** * Do the update * We still need the page_touched condition, in case the row has changed since * the non-locking select above. */ $this->mDb->update( 'page', array( 'page_touched' => $now ), array( 'page_id IN (' . $this->mDb->makeList( $ids ) . ')', 'page_touched < ' . $this->mDb->addQuotes( $now ) ), __METHOD__ ); } }