Getting Started with Memcache
Memcache is a tool which can cache objects in memory – and is often used for speeding up dynamic web applications. PHP has a built-in module for working with memcache, and its a simple and convenient way of introducing caching to your application.
PHP has a PECL module for talking to memcached – look up how to install for your system, but be aware that it isn’t bundled. It’s a good module to include on your system however, quite a few apps will take advantage of it where available.
Memcache is object storage, objects are stored in a serialised manner in RAM, with a unique key to identify them. This means that you need a unique string to identify any object you may store in the cache. Primary keys work fine but look out for when you are storing multiple types of object in there –
The storage persists as long as the machine is on – a reboot empties the RAM and therefore clears the cache. You can also set how long a cached object is valid for. After that time, memcache will return false when you request your object and your code will fall through to its usual retrieval process.