PHP7 installation Redis extension in Linux
1. Sequentially executes
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. Join PHP.ini
3. Restart httpd
4. View probe
WindowsPHP7 installation Redis Extension
This provides a php5.3 version of the Redis PHP expansion Compression Pack (which has a DLL): Https://github.com/nicolasff/phpredis/downloads
After decompression, put the DLL in the EXT directory of PHP, open php.ini, add a line:
Extension=php_redis.dll
and restart Apache.
Example
<?php
Gets the ID of the information for the vote
$aid = isset ($_get[' aid '])? Ereg_replace ("[^0-9]", "", $_get[' aid ']): 0;
The current number of votes, referring to the data in the Redis
$this _click_num = 0;
if ($aid >2) {
Set the maximum number of votes to write back, and write back to MySQL at this value
$update _till_num = 50;
Creating Redis Objects
$r = new Redis ();
$r->connect (' 127.0.0.1 ', 6379);
Got the first few data now.
$this _click_num = $r->get (' count_xin_newgame: '. $aid);
Number of clicks plus 1
$r->set (' Count_xin_newgame: $aid, $this _click_num+1);
if ($this _click_num>= $update _till_num)
{
If the number of clicks exceeds the set number, then write the data to MySQL
if ($this _click_num> $update _till_num)
Require_once (DirName (__file__). " /db.php ");
Update Database
$db->executenonequery (
"UPDATE ' Addonnewgame '
SET ' game_num ' = Game_num + ' {$update _till_num} '
WHERE ' dede_addonnewgame '. ' Aid ' ={$aid};
);
Number of reset votes 0
$r->set (' count_xin_newgame: '. $aid, 0);
}
$r->settimeout (' Count_xin_newgame: $aid, 7*24*60*60);
Exit ($this _click_num);
}
?>