本文整理汇总了PHP中config::get_logic方法的典型用法代码示例。如果您正苦于以下问题:PHP config::get_logic方法的具体用法?PHP config::get_logic怎么用?PHP config::get_logic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config
的用法示例。
在下文中一共展示了config::get_logic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_slave_redis
public static function get_slave_redis($source_name)
{
if (!isset(self::$redis_nodes['slave'][$source_name])) {
$dsns = config::get_logic('redis.' . $source_name . '.slaves', []);
if ($dsns === []) {
$dsns = array(config::get_logic('redis.' . $source_name . '.master'));
}
$all_attempts_failed = true;
foreach ($dsns as $dsn) {
$url_parts = parse_url($dsn);
extract($url_parts, EXTR_SKIP);
$redis_node = new redis_slave_node();
if ($redis_node->connect($host, $port, 2)) {
self::$redis_nodes['slave'][$source_name] = $redis_node;
$all_attempts_failed = false;
break;
} else {
logger::log_error("cannot connect to dsn: '{$dsn}', maybe failed?");
}
}
if ($all_attempts_failed) {
throw new server_except("cannot connect to all dsns of redis source: {$source_name}");
}
}
return self::$redis_nodes['slave'][$source_name];
}
示例2: get_cache
public static function get_cache($cache_name)
{
static $caches = [];
if (!array_key_exists($cache_name, $caches)) {
$dsns = config::get_logic('cache.' . $cache_name);
list($cache_type, ) = explode('://', current($dsns), 2);
$cache_class = __NAMESPACE__ . '\\' . $cache_type . '_cache';
$cache = new $cache_class($dsns);
$caches[$cache_name] = $cache;
}
return $caches[$cache_name];
}
示例3: get_mover
public static function get_mover($target_name)
{
static $movers = [];
if (!isset($movers[$target_name])) {
$dsn = config::get_logic('mover.' . $target_name);
list($mover_type, ) = explode('://', $dsn, 2);
$mover_class = __NAMESPACE__ . '\\' . $mover_type . '_mover';
if (!class_exists($mover_class, true)) {
throw new developer_error("mover: '{$mover_class}' does not exist");
}
$mover = new $mover_class($dsn);
$movers[$target_name] = $mover;
}
return $movers[$target_name];
}
示例4: get_source_name_from_table_name
protected static function get_source_name_from_table_name($table_name)
{
$source_name = config::get_logic('rdb.tables.' . $table_name, null);
if ($source_name === null) {
$source_name = config::get_logic('rdb.tables.*');
}
return $source_name;
}