hyperf 框架 redis 安装和使用
安装Redis 的框架扩张
composer require hyperf/redis
配置redis的参数 -> .env文件中
REDIS_HOST=127.0.0.1 REDIS_AUTH=Fl REDIS_PORT=6379 REDIS_DB=0
在模型文件中
<?php declare(strict_types=1);
namespace App\Model\Data;
use App\Model\Entity\IndexModel;
use Hyperf\Redis\Redis;
use Hyperf\Utils\ApplicationContext;
class IndexData
{
private $redis;
public function IndexDataTest(){
$IndexModel = new IndexModel();
$container = ApplicationContext::getContainer();
$redis = $container->get(\Redis::class);
$result = $redis->keys('*');
print_r($result);
$res = $IndexModel->IndexModelTest();
return $res;
}
}
?>



浙公网安备 33010602011771号