Thinkphp5怎么扩展Redis数据库,实现Redis的CURD操作
1个回答
展开全部
具体代码如下:
namespace app\index\controller;
use \think\Db;
use think\cache\driver\Redis;
class Index
{
public function index()
{
$config = [
'host' => '服务器IP地址',
'port' => Redis端口号,
'password' => 'Redis访问密码',
'select' => 0,
'timeout' => 0,
'expire' => 0,
'persistent' => false,
'prefix' => '',
];
$Redis=new Redis($config);
$Redis->set("test","test");
echo $Redis->get("test");
}
}
namespace app\index\controller;
use \think\Db;
use think\cache\driver\Redis;
class Index
{
public function index()
{
$config = [
'host' => '服务器IP地址',
'port' => Redis端口号,
'password' => 'Redis访问密码',
'select' => 0,
'timeout' => 0,
'expire' => 0,
'persistent' => false,
'prefix' => '',
];
$Redis=new Redis($config);
$Redis->set("test","test");
echo $Redis->get("test");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询