PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Script-Tutorials.com: How to use Memcache with PHP

Note: This article was originally published at PHPDeveloper on 29 September 2011.
PHPDeveloper

In a new tutorial from the Script-Tutorials.com site, they introduce you to memcache, an external caching tool that can help speed up the performance of your application dramatically.

Today we will talking about caching in PHP again. I will show you how you can use Memcache in PHP. We will prepare useful class for working with Memcache for us and several examples. Memcache itself providing procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

Included in the article is a simple "CacheMemcache" class that handles the dirty work for you of connecting to the memcache instance and pushing/pulling the data from the remote source. Also included are a few examples of its use - storing simple objects, pulling the same data back out and deleting a record. The source for the tutorial can be downloaded here. You can also find out more about using memcache in the PHP manual (Note: it does require an extension to be loaded to support this functionality).