12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
建站问答 时间:2024-12-01 19:06:36
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
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();
}
}
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19