Efficient Page View Counter using PHP and Memcache

created March 8, 2013, last updated February 24, 2017.

closeThis post was last updated 9 years 9 months 15 days ago, some of the information contained here may no longer be actual and any referenced software versions may have been updated!

Are you looking for the most efficient way to increment a counter to use on a web page e.g. to display specific page views or amount of times an object is requested? Memcache provides a really fast method of incrementing a simple counter. You can then decide to sync the counter data to your database when required, i.e. every 100 views. The demonstration below uses my DB and memcache PHP wrapper classes to increment a simple counter held in a mysql table and incremented via memcache.


This site uses Akismet to reduce spam. Learn how your comment data is processed.