• ADADADADAD

    tp5如何安装配置使用redis[ 建站问答 ]

    建站问答 时间:2024-12-01 19:06:36

    作者:文/会员上传

    简介:

    tp5安装配置使用redis的方法:1.php安装redis扩展。2.在tp里找到config.php配置文件,再找到cache,修改成如下配置。'cache' => [// 选择模式'type' => 'complex',// 默认(文件缓

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    tp5安装配置使用redis的方法:

    1.php安装redis扩展。

    2.在tp里找到config.php配置文件,再找到cache,修改成如下配置。

    'cache' => [

    // 选择模式

    'type' => 'complex',

    // 默认(文件缓存)

    'default'=>[

    // 驱动方式

    'type' => 'File',

    // 缓存保存目录

    'path' => CACHE_PATH,

    // 缓存前缀

    'prefix' => '',

    // 缓存有效期 0表示永久缓存

    'expire' => 0,

    ],

    //redis缓存设置

    'redis' => [

    // 驱动方式

    'type' => 'redis',

    // 服务器地址

    'host' => '127.0.0.1', //redis服务器ip

    'password' => '',

    'port' => '6379',

    'password'=> "",

    'timeout' => 3600

    ],

    ],

    3.最后在控制器中使用以下代码测试。

    <?php

    namespace app\index\controller;

    class Index

    {

    public $redis;

    public function __construct(){

    $this->redis = new \Redis();

    $this->redis->connect('127.0.0.1',6379);

    }

    public function index()

    {

    $redis = $this->redis;

    echo $redis->ping();

    }

    }

    tp5如何安装配置使用redis.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: redistp5