From a58285588a170281ae64857b98d323dc19d5ef2d Mon Sep 17 00:00:00 2001 From: Steven Benner Date: Thu, 12 Jul 2012 22:33:37 -0700 Subject: [PATCH] More improvements to object caching section. --- _posts/10-03-01-Object-Caching.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/_posts/10-03-01-Object-Caching.md b/_posts/10-03-01-Object-Caching.md index fd8fff9..df29b2e 100644 --- a/_posts/10-03-01-Object-Caching.md +++ b/_posts/10-03-01-Object-Caching.md @@ -4,19 +4,22 @@ isChild: true ## Object Caching -There are times when it can be advantageous to cache individual objects in your code, such as with data that is -expensive to get or database calls where the result is unlikely to change. You can use object caching software to hold -these pieces of data in memory for extremely fast access later on. If you save these items to a data store after you -retrieve them, then pull them directly from the cache for following requests you can gain a significant improvement in -performance as well as reduce load on your database servers. +There are times when it can be beneficial to cache individual objects in your code, such as with data that is expensive +to get or database calls where the result is unlikely to change. You can use object caching software to hold these +pieces of data in memory for extremely fast access later on. If you save these items to a data store after you retrieve +them, then pull them directly from the cache for following requests you can gain a significant improvement in +performance as well as reduce the load on your database servers. -The most commonly used memory object caching systems are APC and memcached. APC is a great choice for object caching as -well as opcode caching *(see above)*. APC comes bundled with PHP and it is very easy to setup and to use, the only -possible downside is that it is tied to the server it is installed on. Memcached on the other hand is installed as a -separate service and can be accessed across the network, meaning that you can store objects in a hyper-fast data store -in a central location and many different systems can pull from it. +Many of the popular bytecode caching solutions let you cache custom data as well, so there's even more reason to take +advantage of them. APC, XCache, and WinCache all provide APIs to save data from your PHP code to their memory cache. -In a networked configuration APC will usally outperform memcached in terms of access speed, but memcached will be able +The most commonly used memory object caching systems are APC and memcached. APC is an excellent choice for object +caching, it includes a simple API for adding your own data to its memory cache and is very easy to setup and use. The +one real limitation of APC is that it is tied to the server it's installed on. Memcached on the other hand is installed +as a separate service and can be accessed across the network, meaning that you can store objects in a hyper-fast data +store in a central location and many different systems can pull from it. + +In a networked configuration APC will usually outperform memcached in terms of access speed, but memcached will be able to scale up faster and further. If you do not expect to have multiple servers running your application, or do not need the extra features that memcached offers then APC is probably your best choice for object caching. @@ -32,10 +35,10 @@ if (!$data) } {% endhighlight %} -Learn more about popular object caching systems. +Learn more about popular object caching systems: -* [APC](http://php.net/manual/en/book.apc.php) (Can do opcode caching and object caching) * [APC Functions](http://php.net/manual/en/ref.apc.php) * [Memcached](http://memcached.org/) * [Redis](http://redis.io/) -* [WinCache](http://php.net/manual/en/book.wincache.php) (Windows Only, can do opcode caching and object caching) +* [XCache APIs](http://xcache.lighttpd.net/wiki/XcacheApi) +* [WinCache Functions](http://www.php.net/manual/en/ref.wincache.php)