Advanced PHP Cache (APC)

APC is another specialized cache solution, but unlike Memcache, there's no server pool. You just deal with one server and it's the server running your application. This also implies that your server needs to have APC already installed on your server. If it is not, contact your server guy. It's really not a hard install. Since Eden cannot install this, we'll just assume that it is installed. To get started, you'll need to create a cache manager.

Figure 1. Setting up APC
$cache = eden('apc');

There are no real arguments that APC needs to start, which means you can now call the typical setters and getters found on most cache managers.

Figure 2. Typical calls
$cache->set('test', 'test data', 3600); 	// set data in the cache by keyword 
											// set to expire an hour from now
$cache->get('test');				//--> test data
$cache->remove('test');				// invalidates this cache
$cache->clear();					// invalidates all cache objects

So now that we understand all the main methods of the cache manager. Let's show how we can form a simple cache process.

Figure 3. Simple Cache Example
$test = $cache->get('test');
if(!trim($test)) {							//if there is no data
	$test = 'something data '.time();		//form the data
	$cache->set('test', $test, 3600);	//cache the data

//either way echo test
echo $test;

Figure 3 shows that we are using a cache object called test which is set to rebuild every hour. We left the option of which caching solution you prefer and it should always be based on the scale of the project. If you have been reading this documentation from the start we just covered all the low level features of Eden, if you have a good understanding so far, pat yourself on the back because we are going to cover web services (the fun part) next. The first service we are going to cover is A. Google.

© 2012 Openovate Labs. All rights reserved.