新聞中心
ThinkPHP5(TP5)是一款PHP框架,它為開發(fā)者提供了簡單而強大的工具,使開發(fā)者可以在短短的時間內(nèi)完成功能強大的Web應(yīng)用。TP5也可以有效地連接Redis,這里介紹一下如何在TP5中手動連接Redis:

成都創(chuàng)新互聯(lián)公司從2013年開始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站建設(shè)、成都網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元鎮(zhèn)安做網(wǎng)站,已為上家服務(wù),為鎮(zhèn)安各地企業(yè)和個人服務(wù),聯(lián)系電話:028-86922220
一、安裝Redis:
1、從官方網(wǎng)站下載Redis,或者添加官方軟件源(Ubuntu):
sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server
2、下載Redis擴展:
sudo apt-get install php5-redis
3、啟動Redis:
sudo service redis-server start
二、在TP5中配置Redis:
1、在TP5項目中添加Redis連接:
'redis' => [
'type'=> '\think\redis\RedisService',
'hostname'=> '127.0.0.1',
'auth'=> 'YourPassWord',
'port'=> 6379,
'database'=> 15
]
2、在TP5中使用Redis:
$RedisConfig = [
‘type’=> '\think\redis\RedisService',
'hostname'=> '127.0.0.1',
'auth'=> 'YourPassWord',
'port'=> 6379,
'database'=> 15
];
$redis = new think\cache\driver\Redis($RedisConfig);
//存儲數(shù)據(jù):
$key = 'hello';
$value = 'world';
$redis->set($key, $value);
//獲取數(shù)據(jù):
$result = $redis->get($key);
echo $result;
以上就是在TP5中如何手動連接Redis的實現(xiàn)方法,我們可以根據(jù)自己的需要對其進行調(diào)整,實現(xiàn)TP5中的Redis數(shù)據(jù)庫連接。
成都服務(wù)器托管選創(chuàng)新互聯(lián),先上架開通再付費。
創(chuàng)新互聯(lián)(www.cdcxhl.com)專業(yè)-網(wǎng)站建設(shè),軟件開發(fā)老牌服務(wù)商!微信小程序開發(fā),APP開發(fā),網(wǎng)站制作,網(wǎng)站營銷推廣服務(wù)眾多企業(yè)。電話:028-86922220
網(wǎng)頁標題:TP5L連接Redis一步一步實現(xiàn)(tp5l連接redis)
當(dāng)前鏈接:http://www.5511xx.com/article/dheohho.html


咨詢
建站咨詢
