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;
    }
}

?>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM