update to 2.2.5 version

add saveToJson and loadFromJson function for DataProvider.php
fix @OnSave annotation not working
adjust swoole timer tick
add hasKey() for WorkerCache.php
This commit is contained in:
jerry
2021-02-15 15:15:26 +08:00
parent f137f044d0
commit f677b0e132
8 changed files with 92 additions and 6 deletions

View File

@@ -39,6 +39,16 @@ class WorkerCache
}
}
public static function hasKey($key, $subkey) {
$config = self::$config ?? ZMConfig::get("global", "worker_cache") ?? ["worker" => 0];
if ($config["worker"] === server()->worker_id) {
return isset(self::$store[$key][$subkey]);
} else {
$action = ["hasKeyWorkerCache", "key" => $key, "subkey" => $subkey, "cid" => zm_cid()];
return self::processRemote($action, false, $config);
}
}
private static function processRemote($action, $async, $config) {
$ss = server()->sendMessage(json_encode($action, JSON_UNESCAPED_UNICODE), $config["worker"]);
if (!$ss) return false;