1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.application.available-resources.cachemanager">
4 <title>Zend_Application_Resource_Cachemanager</title>
7 <classname>Zend_Application_Resource_Cachemanager</classname> may be
8 utilised to configure a set of <classname>Zend_Cache</classname> option
9 bundles for use when lazy loading caches using
10 <classname>Zend_Cache_Manager</classname>
14 As the Cache Manager is a lazy loading mechanism, the options are translated
15 to option templates used to instantiate a cache object on request.
18 <example id="zend.application.available-resources.cachemanager.configExample">
19 <title>Sample Cachemanager resource configuration</title>
22 Below is a sample <acronym>INI</acronym> file showing how
23 <classname>Zend_Cache_Manager</classname> may be configured. The format
24 is the Cachemanager resource prefix (<property>resources.cachemanager</property>)
25 followed be the name to assign to an option cache template or bundle (e.g.
26 <property>resources.cachemanager.database</property>) and finally followed by a
27 typical <classname>Zend_Cache</classname> option.
30 <programlisting language="ini"><![CDATA[
31 resources.cachemanager.database.frontend.name = Core
32 resources.cachemanager.database.frontend.customFrontendNaming = false
33 resources.cachemanager.database.frontend.options.lifetime = 7200
34 resources.cachemanager.database.frontend.options.automatic_serialization = true
35 resources.cachemanager.database.backend.name = File
36 resources.cachemanager.database.backend.customBackendNaming = false
37 resources.cachemanager.database.backend.options.cache_dir = "/path/to/cache"
38 resources.cachemanager.database.frontendBackendAutoload = false
42 Actually retrieving this cache from the Cache Manager is as simple as
43 accessing an instance of the Manager (<classname>Zend_Cache_Manager</classname>)
44 retrieved from <classname>Zend_Application_Resource_Cachemanager</classname> and
45 calling <methodname>Zend_Cache_Manager::getCache('database')</methodname>. The example
46 below is taken from a controller where the bootstrap class can be accessed as
47 a Front Controller parameter (which is automatically assigned during bootstrapping).
48 As you can see, the Cache Manager Resource implements a
49 <methodname>getCacheManager()</methodname> method to retrieve the bootstrapped instance
50 of <classname>Zend_Cache_Manager</classname>.
53 <programlisting language="php"><![CDATA[
54 $manager = $this->getFrontController()
55 ->getParam('bootstrap')
56 ->getResource('cachemanager')
58 $dbCache = $manager->getCache('database');
62 See <methodname>Zend_Cache::factory()</methodname> method to get a
63 description of the default values you can assign when configuring a
64 cache via a configuration file such as out example <acronym>INI</acronym> file above.