fix review

This commit is contained in:
sunxyw 2022-03-21 23:28:57 +08:00
parent bc7d5871e4
commit 8105892b6e
No known key found for this signature in database
GPG Key ID: CEA01A083E98C578
2 changed files with 4 additions and 21 deletions

View File

@ -83,9 +83,9 @@ class EventManager
}
$conf = ZMConfig::get('global', 'worker_cache') ?? ['worker' => 0];
if (server()->worker_id == $conf['worker']) {
run_repeating(static function () {
zm_timer_tick(ZMConfig::get('global', 'light_cache')['auto_save_interval'] * 1000, static function () {
LightCache::savePersistence();
}, ZMConfig::get('global', 'light_cache')['auto_save_interval'] * 1000);
});
}
}
}

View File

@ -345,7 +345,7 @@ function zm_resume(int $cid)
*
* @param int $delay 延迟时间单位毫秒ms
*/
function run_later(callable $runnable, int $delay)
function zm_timer_after(int $delay, callable $runnable)
{
Swoole\Timer::after($delay, static function () use ($runnable) {
call_with_catch($runnable);
@ -358,7 +358,7 @@ function run_later(callable $runnable, int $delay)
* @param int $interval 间隔时间单位毫秒ms
* @return false|int 定时器ID失败返回false
*/
function run_repeating(callable $runnable, int $interval)
function zm_timer_tick(int $interval, callable $runnable)
{
if (zm_cid() === -1) {
return go(static function () use ($interval, $runnable) {
@ -719,15 +719,6 @@ function onebot_target_id_name(string $message_type): string
return get_onebot_target_id_name($message_type);
}
/**
* @param mixed $ms
* @deprecated 已废弃,请使用 {@link run_repeating()}
*/
function zm_timer_tick($ms, callable $callable)
{
return run_repeating($callable, $ms);
}
/**
* @deprecated 已废弃,请直接使用 {@link call_with_catch()}
*/
@ -744,11 +735,3 @@ function zm_data_hash($v): string
{
return hash_message($v);
}
/**
* @deprecated 已废弃,请使用 {@link run_later()}
*/
function zm_timer_after(int $ms, callable $callable)
{
run_later($callable, $ms);
}