mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-18 05:04:51 +08:00
🐛 try not to die.
This commit is contained in:
parent
79bb11f6d4
commit
a8c856d816
@ -44,8 +44,8 @@ class CQUtil
|
||||
public static function saveAllFiles() {
|
||||
Console::info("Saving files... ", null, "");
|
||||
|
||||
DP::setJsonDataAsync("bots.json", Cache::get("bots"));
|
||||
DP::setJsonDataAsync("group_list.json", Cache::get("group_list"));
|
||||
DP::setJsonData("bots.json", Cache::get("bots"));
|
||||
DP::setJsonData("group_list.json", Cache::get("group_list"));
|
||||
|
||||
//保存用户数据
|
||||
if (settings()["save_user_data"]) {
|
||||
|
||||
@ -34,7 +34,7 @@ class DataProvider
|
||||
* @return array|mixed
|
||||
*/
|
||||
static function getJsonData($filename){
|
||||
if (!file_exists(self::getDataFolder() . $filename)) return [];
|
||||
if (!file_exists(self::getDataFolder() . $filename)) return array();
|
||||
return json_decode(file_get_contents(self::getDataFolder() . $filename), true);
|
||||
}
|
||||
|
||||
@ -52,11 +52,11 @@ class DataProvider
|
||||
* 储存PHP数组为json文件,文件不存在会创建文件
|
||||
* 此方式为异步非阻塞执行,不会对worker造成阻塞。
|
||||
* @param $filename
|
||||
* @param array $args
|
||||
* @param array $arg
|
||||
* @param callable|null $function
|
||||
*/
|
||||
static function setJsonDataAsync($filename, array $args, callable $function = null) {
|
||||
$data = json_encode($args, 128 | 256);
|
||||
static function setJsonDataAsync($filename, array $arg, callable $function = null) {
|
||||
$data = json_encode($arg, 128 | 256);
|
||||
$filename = self::getDataFolder() . $filename;
|
||||
if ($function === null) swoole_async_writefile($filename, $data, function () { });
|
||||
else swoole_async_writefile($filename, $data, $function);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user