rollback and correct to 398(v2.3.5)

This commit is contained in:
2021-03-23 14:49:42 +08:00
parent 626d569858
commit 235256d679
30 changed files with 207 additions and 1020 deletions

View File

@@ -7,6 +7,7 @@ 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;
@@ -181,12 +182,17 @@ class LightCache
}
/**
* 这个只能在唯一一个工作进程中执行
* @param false $only_worker
* @throws Exception
*/
public static function savePersistence() {
$dispatcher = new EventDispatcher(OnSave::class);
$dispatcher->dispatchEvents();
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;
if (self::$kv_table === null) return;
$r = [];
@@ -201,7 +207,8 @@ 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) {