Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

CloudWays Blog:
Using Memcached With PHP
Apr 13, 2016 @ 18:48:10

On the Cloudways blog they have a new tutorial posted showing you how to use memcached with PHP to help improve the overall performance of your application through cached data.

Memcached is a distributed memory caching system. It speeds up websites having large dynamic databasing by storing database object in Dynamic Memory to reduce the pressure on a server whenever an external data source requests a read. A memcached layer reduces the number of times database requests are made.

[..] Why Memcached? It increases the response time of your web pages, which in return enhances the overall customer’s experience. A better response time allows users to fetch data seamlessly.

He starts by ensuring that you already have a memcached instance up and running (it's external to PHP). They suggest using their own Cloudways setup, but it's relatively easy to install with packages on most Linux distributions. With that verified, he shows how to check for memchace functionality in your PHP installation and provides a bit of code to create a connection. Next is an example showing how to pull information from a MySQL database and push that data directly into the waiting memcache server via a set method call. It also includes a get example, showing if the caching was a success or not.

tagged: memcached caching tutorial introduction server configuration example

Link: http://www.cloudways.com/blog/memcached-with-php/


Trending Topics: