Previously wrote a blog post, using PHP and Memcache to implement the site, the following links to view: http://www.jb51.net/article/51825.htm
Today the feature is used in WordPress, and the implementation of the number of visits saved to the database.
MySQL statement
First, in the parameter table, add the default data for the number of accesses
Get all browse times function Get_all_visit_number () {$MC = new Memcache ();
Use WordPress with wpdb class global $wpdb;
Parameter table $table = "Wp_options";
Connection Memcache $MC->connect ("127.0.0.1", 11211);
Get browse times $visit _number = $MC->get (' Visit_number '); Memcache if (! $visit _number) {//does not exist, query database $querystr = ' select ' Option_value ' from '. $table. "
WHERE ' option_name ' = ' visit_number ';
$results = $wpdb->get_results ($QUERYSTR);
Assign the value stored in the database to the memcache variable $visit _number = Intval ($results [0]->option_value);
/set Browse times $MC->set (' visit_number ', + + $visit _number);
Get browse times $visit _number = $MC->get (' Visit_number '); 100 visits per visit, updated to database if ($visit _number% 100 = 0) {//Use WordPress self-with wpdb class $data _array = Array (' Option_value ' =>
$visit _number);
$where _clause = Array (' option_name ' => ' visit_number ');
$wpdb->update ($table, $data _array, $where _clause);
}//Close memcache connection $MC->close (); Return $visit_number;
}