How to reduce page load time using PHP Memcache

Dream. Dare. Do – that is Suyati’s work principle in a nutshell.

Apr
09
2013
  • Author:
  • NaveenBos

Memcache is used for reducing the database load in dynamic web applications. Memcache is a cross platform technology and works on Linux, Unix, Windows and Mac. Memcache is mainly used for reducing the database load time by improving the database results speed. Once the data is loaded, there is no need for retrieving it again from database and the data will cache for further use. Here is how you can implement memcache in php to achieve improved page load time.

Reduced Search Queries and page load time

First, create the database connection page file in php.

dbconnect.php

db1

 

Create another file called as memcache.php

Establishing a new connection with memcache is shown below.

mem1

After the memcache connection, include the database file.

connincl1

The below code is used for memcache and MySQL query for getting data from database.

valueass_mem1

If the result is available in the $get_queyresult variable the following code will work otherwise it will go to else case.

ifchk1

elsechk1

Leave a Comment

Your email address will not be published. Required fields are marked *