tmp connect

This commit is contained in:
jerry
2021-03-22 07:44:11 +08:00
parent b6d1f724e9
commit 0ff4e52ed3
26 changed files with 812 additions and 212 deletions

View File

@@ -7,7 +7,6 @@ namespace ZM\Store;
use Exception;
use Swoole\Table;
use ZM\Annotation\Swoole\OnSave;
use ZM\Config\ZMConfig;
use ZM\Console\Console;
use ZM\Event\EventDispatcher;
use ZM\Exception\ZMException;
@@ -182,17 +181,12 @@ class LightCache
}
/**
* @param false $only_worker
* 这个只能在唯一一个工作进程中执行
* @throws Exception
*/
public static function savePersistence($only_worker = false) {
// 下面将OnSave激活一下
if (server()->worker_id == (ZMConfig::get("global", "worker_cache")["worker"] ?? 0)) {
$dispatcher = new EventDispatcher(OnSave::class);
$dispatcher->dispatchEvents();
}
if($only_worker) return;
public static function savePersistence() {
$dispatcher = new EventDispatcher(OnSave::class);
$dispatcher->dispatchEvents();
if (self::$kv_table === null) return;
$r = [];
@@ -207,8 +201,7 @@ class LightCache
$r = file_put_contents(self::$config["persistence_path"], json_encode($r, 128 | 256));
if ($r === false) Console::error("Not saved, please check your \"persistence_path\"!");
}
Console::verbose("Saved.");
}
private static function checkExpire($key) {