2.2. Zend_Cache factory

There is only one way to build a Zend_Cache_* object. In all cases (backends and/or frontends), you have to use the Zend_Cache factory. Do not use frontends constructors directly, it won't work correctly !

The good way to build an usable instance of Zend_Cache_* is given in the following example :

<?php
    	
# We "load" the Zend_Cache factory 
require 'Zend/Cache.php'; 

# We choose a backend (for example 'File' or 'Sqlite'...)
$backendName = '[...]';

# We choose a frontend (for example 'Core', 'Output', 'Page'...)
$frontendName = '[...]';

# We set an array of options for the choosen frontend
$frontendOptions = array([...]);

# We set an array of options for the choosen backend
$backendOptions = array([...]);

# We make the good instance 
# (of course, the two last arguments are optional)
$cache = Zend_Cache::factory($frontendName, $backendName, $frontendOptions, $backendOptions);

[...]

?>   

In next lines of this documentation, we will assume that the $cache variable is set as shown in the previous example.