PHP7安裝Redis擴(kuò)展教程【Linux與Windows平臺(tái)】
本文實(shí)例講述了PHP7安裝Redis擴(kuò)展的方法。分享給大家供大家參考,具體如下:
linux中PHP7安裝Redis擴(kuò)展
1.依次執(zhí)行
wget -c https://github.com/phpredis/phpredis/archive/php7.zip unzip php7.zip cd phpredis-php7 /YouPath/phpize ./configure --with-php-config=/YouPath/php-config make make install
2.加入php.ini
3.重啟httpd
4.查看探針
windowsPHP7安裝Redis擴(kuò)展
這里提供php5.3版本的redis的php擴(kuò)展壓縮包(里面有個(gè)dll):https://github.com/nicolasff/phpredis/downloads
解壓后把dll放到php的ext目錄下,打開php.ini,增加一行:
extension=php_redis.dll
然后重啟apache即可
例子:
<?php
//獲取投票的信息的ID
$aid = isset($_GET['aid']) ? ereg_replace("[^0-9]", "", $_GET['aid']) : 0;
//當(dāng)前投票的數(shù)字,指的是在redis中的數(shù)據(jù)
$this_click_num = 0;
if($aid>2){
//設(shè)定寫回的投票數(shù)的最大值,到了此值就寫回mysql
$update_till_num = 50;
//創(chuàng)建redis對(duì)象
$r = new Redis();
$r->connect('127.0.0.1',6379);
//得到現(xiàn)在是第幾個(gè)數(shù)據(jù)了
$this_click_num = $r->get('count_xin_newgame:'.$aid);
//點(diǎn)擊數(shù)加1
$r->set('count_xin_newgame:'.$aid,$this_click_num+1);
if($this_click_num>=$update_till_num)
{
//如果點(diǎn)擊數(shù)超過了設(shè)定數(shù),那么就把數(shù)據(jù)寫到mysql
if($this_click_num>$update_till_num)
require_once(dirname(__FILE__)."/db.php");
//更新數(shù)據(jù)庫
$db->ExecuteNoneQuery(
"UPDATE `addonnewgame`
SET `game_num` = game_num + '{$update_till_num}'
WHERE `dede_addonnewgame`.`aid` ={$aid};"
);
//重置投票數(shù)目為0
$r->set('count_xin_newgame:'.$aid,0);
}
$r->setTimeout('count_xin_newgame:'.$aid,7*24*60*60);
exit($this_click_num);
}
?>
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP擴(kuò)展開發(fā)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計(jì)算法總結(jié)》、《php正則表達(dá)式用法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。
相關(guān)文章
PHP翻頁跳轉(zhuǎn)功能實(shí)現(xiàn)方法
這篇文章主要介紹了PHP翻頁跳轉(zhuǎn)功能實(shí)現(xiàn)方法,下面就來介紹一下如何實(shí)現(xiàn)當(dāng)前頁面數(shù)據(jù)資料顯示數(shù)量及如何實(shí)現(xiàn)動(dòng)態(tài)的翻轉(zhuǎn)功能,需要的朋友可以參考下2015-11-11
PHP讀取XML文件的方法實(shí)例總結(jié)【DOMDocument及simplexml方法】
這篇文章主要介紹了PHP讀取XML文件的方法,結(jié)合實(shí)例形式總結(jié)分析了php基于DOMDocument及simplexml方法針對(duì)xml文件的載入、讀取等相關(guān)操作技巧,需要的朋友可以參考下2019-09-09

