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


Zend_Application_Resource_Cachemanager may be utilised to configure a set of Zend_Cache option bundles for use when lazy loading caches using Zend_Cache_Manager

As the Cache Manager is a lazy loading mechanism, the options are translated to option templates used to instantiate a cache object on request.

Example 31. Sample Cachemanager resource configuration

Below is a sample INI file showing how Zend_Cache_Manager may be configured. The format is the Cachemanager resource prefix (resources.cachemanager) followed be the name to assign to an option cache template or bundle (e.g. resources.cachemanager.database) and finally followed by a typical Zend_Cache option. = Core
resources.cachemanager.database.frontend.customFrontendNaming = false
resources.cachemanager.database.frontend.options.lifetime = 7200
resources.cachemanager.database.frontend.options.automatic_serialization = true = File
resources.cachemanager.database.backend.customBackendNaming = false
resources.cachemanager.database.backend.options.cache_dir = "/path/to/cache"
resources.cachemanager.database.frontendBackendAutoload = false

Actually retrieving this cache from the Cache Manager is as simple as accessing an instance of the Manager (Zend_Cache_Manager) retrieved from Zend_Application_Resource_Cachemanager and calling Zend_Cache_Manager::getCache('database'). The example below is taken from a controller where the bootstrap class can be accessed as a Front Controller parameter (which is automatically assigned during bootstrapping). As you can see, the Cache Manager Resource implements a getCacheManager() method to retrieve the bootstrapped instance of Zend_Cache_Manager.

$dbCache $manager->getCache('database');

See Zend_Cache::factory() method to get a description of the default values you can assign when configuring a cache via a configuration file such as out example INI file above.

Zend Framework