当前位置: 首页>>代码示例>>PHP>>正文


PHP Database::ignoreTarget方法代码示例

本文整理汇总了PHP中Drupal\Core\Database\Database::ignoreTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::ignoreTarget方法的具体用法?PHP Database::ignoreTarget怎么用?PHP Database::ignoreTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Database\Database的用法示例。


在下文中一共展示了Database::ignoreTarget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkReplicaServer

 /**
  * Checks and disables the replica database server if appropriate.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *   The Event to process.
  */
 public function checkReplicaServer(GetResponseEvent $event)
 {
     // Ignore replica database servers for this request.
     //
     // In Drupal's distributed database structure, new data is written to the
     // master and then propagated to the replica servers.  This means there is a
     // lag between when data is written to the master and when it is available
     // on the replica. At these times, we will want to avoid using a replica server
     // temporarily. For example, if a user posts a new node then we want to
     // disable the replica server for that user temporarily to allow the replica
     // server to catch up.
     // That way, that user will see their changes immediately while for other
     // users we still get the benefits of having a replica server, just with
     // slightly stale data.  Code that wants to disable the replica server should
     // use the db_set_ignore_replica() function to set
     // $_SESSION['ignore_replica_server'] to the timestamp after which the replica
     // can be re-enabled.
     if (isset($_SESSION['ignore_replica_server'])) {
         if ($_SESSION['ignore_replica_server'] >= REQUEST_TIME) {
             Database::ignoreTarget('default', 'replica');
         } else {
             unset($_SESSION['ignore_replica_server']);
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:31,代码来源:ReplicaDatabaseIgnoreSubscriber.php

示例2: testConnectionRoutingOverride

 /**
  * Tests that connections return appropriate connection objects.
  */
 function testConnectionRoutingOverride()
 {
     // Clone the primary credentials to a replica connection.
     // Note this will result in two independent connection objects that happen
     // to point to the same place.
     $connection_info = Database::getConnectionInfo('default');
     Database::addConnectionInfo('default', 'replica', $connection_info['default']);
     Database::ignoreTarget('default', 'replica');
     $db1 = Database::getConnection('default', 'default');
     $db2 = Database::getConnection('replica', 'default');
     $this->assertIdentical($db1, $db2, 'Both targets refer to the same connection.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:15,代码来源:ConnectionTest.php

示例3: ignoreTarget

 public static function ignoreTarget($key, $target)
 {
     BaseDatabase::ignoreTarget($key, $target);
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:4,代码来源:Database.php


注:本文中的Drupal\Core\Database\Database::ignoreTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。