本文整理汇总了PHP中LoadBalancer::getWriterIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP LoadBalancer::getWriterIndex方法的具体用法?PHP LoadBalancer::getWriterIndex怎么用?PHP LoadBalancer::getWriterIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadBalancer
的用法示例。
在下文中一共展示了LoadBalancer::getWriterIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shutdownLB
/**
* Notify the ChronologyProtector that the LoadBalancer is about to shut
* down. Saves replication positions.
*
* @param LoadBalancer $lb
* @return void
*/
public function shutdownLB(LoadBalancer $lb)
{
if (!$this->enabled || $lb->getServerCount() <= 1) {
return;
// non-replicated setup or disabled
}
$info = $lb->parentInfo();
$masterName = $lb->getServerName($lb->getWriterIndex());
// Only save the position if writes have been done on the connection
$db = $lb->getAnyOpenConnection($lb->getWriterIndex());
if (!$db || !$db->doneWrites()) {
wfDebugLog('replication', __METHOD__ . ": LB {$info['id']}, no writes done\n");
return;
// nothing to do
}
$pos = $db->getMasterPos();
wfDebugLog('replication', __METHOD__ . ": LB {$info['id']} has master pos {$pos}\n");
$this->shutdownPositions[$masterName] = $pos;
}
示例2: getLagTimeCacheKey
private function getLagTimeCacheKey()
{
$writerIndex = $this->parent->getWriterIndex();
// Lag is per-server, not per-DB, so key on the master DB name
return $this->srvCache->makeGlobalKey('lag-times', $this->parent->getServerName($writerIndex));
}