forked from easy-swoole/easyswoole
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
31 changed files
with
417 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
namespace EasySwoole\EasySwoole; | ||
|
||
|
||
use EasySwoole\Component\Singleton; | ||
use EasySwoole\Spl\SplArray; | ||
use Swoole\Table; | ||
|
@@ -25,28 +26,28 @@ public function __construct() | |
* 用于存储动态配置,不适合存储大量\大长度的的配置下,仅仅建议用于开关存储 | ||
*/ | ||
$this->swooleTable = new \swoole_table(1024); | ||
$this->swooleTable->column('value', Table::TYPE_STRING, 512); | ||
$this->swooleTable->column('value',Table::TYPE_STRING,512); | ||
$this->swooleTable->create(); | ||
} | ||
|
||
public function setDynamicConf($key, $val) | ||
function setDynamicConf($key,$val) | ||
{ | ||
$this->swooleTable->set($key, [ | ||
'value' => serialize($val), | ||
$this->swooleTable->set($key,[ | ||
'value'=> serialize($val) | ||
]); | ||
} | ||
|
||
public function getDynamicConf($key) | ||
function getDynamicConf($key) | ||
{ | ||
$data = $this->swooleTable->get($key); | ||
if (!empty($data)) { | ||
if(!empty($data)){ | ||
return unserialize($data['value']); | ||
} else { | ||
}else{ | ||
return null; | ||
} | ||
} | ||
|
||
public function delDynamicConf($key) | ||
function delDynamicConf($key) | ||
{ | ||
$this->swooleTable->del($key); | ||
} | ||
|
@@ -68,7 +69,7 @@ public function getConf($keyPath = '') | |
* 设置配置项 | ||
* 在server启动以后,无法动态的去添加,修改配置信息(进程数据独立) | ||
* @param string $keyPath 配置项名称 支持点语法 | ||
* @param mixed $data 配置项数据 | ||
* @param mixed $data 配置项数据 | ||
*/ | ||
public function setConf($keyPath, $data): void | ||
{ | ||
|
@@ -96,7 +97,7 @@ public function load(array $conf): void | |
/** | ||
* 载入一个文件的配置项 | ||
* @param string $filePath 配置文件路径 | ||
* @param bool $merge 是否将内容合并入主配置 | ||
* @param bool $merge 是否将内容合并入主配置 | ||
* @author : evalor <[email protected]> | ||
*/ | ||
public function loadFile($filePath, $merge = false) | ||
|
@@ -116,15 +117,15 @@ public function loadFile($filePath, $merge = false) | |
|
||
public function loadEnv(string $file) | ||
{ | ||
if (file_exists($file)) { | ||
if(file_exists($file)){ | ||
$data = require $file; | ||
$this->conf->loadArray($data); | ||
} else { | ||
}else{ | ||
throw new \Exception("config file : {$file} is miss"); | ||
} | ||
} | ||
|
||
public function clear() | ||
function clear() | ||
{ | ||
$this->conf = new SplArray(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ public function set($key, CommandInterface $command) | |
$this->container[$key] = $command; | ||
} | ||
|
||
public function get($key): ?CommandInterface | ||
function get($key): ?CommandInterface | ||
{ | ||
if (isset($this->container[$key])) { | ||
return $this->container[$key]; | ||
|
@@ -37,7 +37,7 @@ public function get($key): ?CommandInterface | |
* @return array | ||
* @author: eValor < [email protected] > | ||
*/ | ||
public function getCommandList() | ||
function getCommandList() | ||
{ | ||
return array_keys($this->container); | ||
} | ||
|
@@ -49,7 +49,7 @@ public function getCommandList() | |
* @param Response $response | ||
* @author: eValor < [email protected] > | ||
*/ | ||
public function hook($actionName, Caller $caller, Response $response) | ||
function hook($actionName, Caller $caller, Response $response) | ||
{ | ||
$call = CommandContainer::getInstance()->get($actionName); | ||
if ($call instanceof CommandInterface) { | ||
|
@@ -58,4 +58,4 @@ public function hook($actionName, Caller $caller, Response $response) | |
$response->setMessage("action {$actionName} miss"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.