Skip to content
Konrad Abicht edited this page Jul 3, 2013 · 1 revision

The object cache provides a good way to store PHP objects. You can store whatever you want, a string, a number or a big instance of a class.

Initialize ObjectCache

// save reference to the ObjectCache
$objectCache = Erfurt_App::getInstance()->getCache();

Store and get data

$foobar = array ("foo", "bar");
$uniqueId = md5 ("Foo");

// save an object in the object cache
$objectCache->save($foobar, $uniqueId);

You store data using the save function. The first parameter is the object to store, the second a unique identifier. Be aware, you have to remember this unique identifier, to be able to get the object later on.

To get your stored data later on, simply use the load function:

$storedObject = $objectCache->load($uniqueId);

Thats it, enjoy the increased performance :)

Clone this wiki locally