Here's how you do it, assuming you have a memory caching extension active:
(I'm going to use APC as an example here because it will be bundled with PHP 6)
// set this to the current post id
$post_id = get_the_ID();
// this will attempt to get the post view count from cache (the memory)
$page_views = apc_fetch("post_{$post_id}_views");
// if it exists, increase the counter (again, only in memory)
if($page_views !== false){
$page_views = apc_inc("post_{$post_id}_views");
// write the data to the database every ...let's say 100 views
if(($page_views % 10) == 100)
update_your_database_here();
}
// doesn't exist; most likely this is the first view, so create the cache entry
else{
apc_store("post_{$post_id}_views", 1);
$page_views = 1;
}
// show it
printf('This post has %d views', $page_views);
You can choose to use WP's functions - wp_cache_incr() or wp_cache_decr() + W3TC with APC selected. But personally I would avoid using any cache plugins and create my own object cache handler which I can drop in the wp-content directory.
You can also use xcache for this too, it doesn't matter - The idea is that you need to store the count in memory up to a certain point, to avoid any disk writes. Since your site has high-traffic I assume you own a dedicated server, on which you can install your own PHP extensions etc. Shared hosters won't allow you to cache data in memory for obvious reasons...