perf: 增加原生缓存

This commit is contained in:
Ying
2023-06-19 14:36:07 +08:00
parent 2b8f874450
commit 331d7b0582
1486 changed files with 105475 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace app\common\bootstrap;
use support\Cache;
use support\Log;
use think\Container;
use think\DbManager;
use Webman\Bootstrap;
use Workerman\Timer;
use Workerman\Worker;
class RedisCache implements Bootstrap
{
public static function start(?Worker $worker)
{
// TODO: Implement start() method.
if ($worker) {
try {
Timer::add(55, function () {
Cache::get('ping');
});
} catch (\Throwable $e) {
Log::error('RedisCache error: ' . $e->getMessage());
}
}
if (class_exists(DbManager::class)) {
$manager_instance = Container::getInstance()->make(DbManager::class);
$manager_instance->setCache(Cache::instance());
}
}
}