改名
This commit is contained in:
@@ -54,9 +54,11 @@ class Config extends Component
|
||||
*/
|
||||
public static function get($key, $try = FALSE, $default = null)
|
||||
{
|
||||
$explode = explode('.', $key);
|
||||
$instance = Snowflake::app()->config->getData();
|
||||
foreach ($explode as $index => $value) {
|
||||
if (strpos($key, '.') === false) {
|
||||
return isset($instance[$key]) ? $instance[$key] : $default;
|
||||
}
|
||||
foreach (explode('.', $key) as $index => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
@@ -66,10 +68,10 @@ class Config extends Component
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
$instance = $instance[$value];
|
||||
if (!is_array($instance) && $index + 1 < count($explode)) {
|
||||
throw new ConfigException(sprintf(self::ERROR_MESSAGE, $key));
|
||||
if (!is_array($instance[$value]) ) {
|
||||
return $instance[$value];
|
||||
}
|
||||
$instance = $instance[$value];
|
||||
}
|
||||
return empty($instance) ? $default : $instance;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ abstract class Pool extends Component
|
||||
*/
|
||||
public function name($cds, $isMaster = false)
|
||||
{
|
||||
return hash('sha1', $cds . ($isMaster ? 'master' : 'slave'));
|
||||
return md5($cds . ($isMaster ? 'master' : 'slave'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,17 +38,6 @@ class Application extends BaseApplication
|
||||
public $id = 'uniqueId';
|
||||
|
||||
|
||||
/**
|
||||
* Application constructor.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
// instance_load();
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ConfigException
|
||||
* @throws NotFindClassException
|
||||
|
||||
+2
-11
@@ -366,24 +366,15 @@ SCRIPT;
|
||||
*/
|
||||
public function get_config(): array
|
||||
{
|
||||
$config = Config::get('cache.redis', false, [
|
||||
return Config::get('cache.redis', false, [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '6379',
|
||||
'prefix' => Config::get('id'),
|
||||
'auth' => '',
|
||||
'databases' => '0',
|
||||
'read_timeout' => -1,
|
||||
'conn_timeout' => -1,
|
||||
'timeout' => -1,
|
||||
]);
|
||||
return [
|
||||
'host' => $config['host'],
|
||||
'port' => $config['port'],
|
||||
'auth' => $config['auth'],
|
||||
'timeout' => $config['conn_timeout'],
|
||||
'databases' => $config['databases'],
|
||||
'read_timeout' => $config['read_timeout'],
|
||||
'prefix' => $config['prefix'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -131,14 +131,11 @@ class Container extends BaseObject
|
||||
if (empty($config)) {
|
||||
return $reflect->newInstanceArgs($dependencies ?? []);
|
||||
}
|
||||
|
||||
if (!empty($dependencies) && $reflect->implementsInterface('Snowflake\Abstracts\Configure')) {
|
||||
$dependencies[count($dependencies) - 1] = $config;
|
||||
return $reflect->newInstanceArgs($dependencies);
|
||||
}
|
||||
if (!empty($config)) {
|
||||
$this->_param[$class] = $config;
|
||||
}
|
||||
$this->_param[$class] = $config;
|
||||
$object = $reflect->newInstanceArgs($dependencies ?? []);
|
||||
foreach ($config as $key => $val) {
|
||||
$object->{$key} = $val;
|
||||
|
||||
@@ -97,7 +97,7 @@ class Redis extends Pool
|
||||
$config['read_timeout'] = 10;
|
||||
}
|
||||
$redis->select($config['databases']);
|
||||
$redis->setOption(SRedis::OPT_READ_TIMEOUT, -1);
|
||||
$redis->setOption(SRedis::OPT_READ_TIMEOUT, $config['read_timeout']);
|
||||
$redis->setOption(SRedis::OPT_PREFIX, $config['prefix']);
|
||||
return $redis;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user