<?php/** * * Cache Utilization Test, here we get the vote data sent over, each add 1, if added to the set value, will vote * number of times to write back to MySQL, which greatly reduces the cost of the MySQL link, the use of Redis is evident * @var Unknown_ Type * @ From: www.crazyant.net and www.51projob.com *///get poll Info id$aid = isset ($_get[' aid '])? Ereg_replace ("[^0-9]", "" ", $_get[' aid ']): 0;//The current number of votes, refers to data in Redis $this_click_num = 0;if ($aid >2) {//Set the maximum number of votes written back , this value is written back to Mysql$update_till_num = 50;//Creating Redis object = new Redis (); $r->connect (' 127.0.0.1 ', 6379); Get now is the first few data of $this_click_num = $r->get (' count_xin_newgame: '. $aid);//Click on the number 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, write the data to Mysqlif ($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}; /resets the number of votes to 0$r->set (' Count_xin_newgame: '. $aid, 0);} $r->settimeout (' count_xin_newgame: ' $aid, 7*24*60*60); exit ($this _click_num);}? >
Redis Poll Count