db = $db; $this->table = $table; $this->clusterName = $clusterName; } /** * @param array $updates Array of arrays each containing two keys, 'primaryKey' * and 'changes'. primaryKey must contain a map of column names to values * sufficient to uniquely identify the row changes must contain a map of column * names to update values to apply to the row. */ public function write( array $updates ) { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ ); foreach ( $updates as $update ) { $this->db->update( $this->table, $update['changes'], $update['primaryKey'], __METHOD__ ); } $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); } }