国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

Events.php要引入TP里面 緩存cache::set 怎么引入有方法嗎

bl2020

Events.php要引入TP里面 緩存cache::set 怎么引入有方法嗎

2444 1 2
1個回答

six

看他們文檔,有用法
https://github.com/top-think/think-cache

安裝:

composer require topthink/think-cache

然后可以在onWorkerStart里配置Cache,然后就可以在onMessage onXXX里使用了

use think\facade\Cache;
class Events
{
    public static function onWorkerStart()
    {
        Cache::config([
            'default'   =>  'file',
            'stores'    =>  [
                'file'  =>  [
                    'type'   => 'File',
                    // 緩存保存目錄
                    'path'   => './cache/',
                    // 緩存前綴
                    'prefix' => '',
                    // 緩存有效期 0表示永久緩存
                    'expire' => 0,
                ],
                'redis' =>  [
                    'type'   => 'redis',
                    'host'   => '127.0.0.1',
                    'port'   => 6379,
                    'prefix' => '',
                    'expire' => 0,
                ],
            ],
        ]);
    }

    public function onMessage($client_id, $data)
    {
        Cache::get('val');
    }
}
年代過于久遠,無法發(fā)表回答
??