PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

The Zend_Cache Factory Method

A good way to build a usable instance of a Zend_Cache Frontend is given in the following example :

<?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 chosen frontend
$frontendOptions = array([...]);

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

// We create an instance of Zend_Cache
// (of course, the two last arguments are optional)
$cache Zend_Cache::factory($frontendName,
                             
$backendName,
                             
$frontendOptions,
                             
$backendOptions);

In the following examples we will assume that the $cache variable holds a valid, instantiated frontend as shown and that you understand how to pass parameters to your chosen backends.

Note

Always use Zend_Cache::factory() to get frontend instances. Instantiating frontends and backends yourself will not work as expected.

Zend Framework