|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Application |
|
17 * @subpackage Resource |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: Cachemanager.php 20785 2010-01-31 09:43:03Z mikaelkael $ |
|
21 */ |
|
22 |
|
23 require_once 'Zend/Application/Resource/ResourceAbstract.php'; |
|
24 |
|
25 /** |
|
26 * Cache Manager resource |
|
27 * |
|
28 * @category Zend |
|
29 * @package Zend_Application |
|
30 * @subpackage Resource |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 */ |
|
34 class Zend_Application_Resource_Cachemanager extends Zend_Application_Resource_ResourceAbstract |
|
35 { |
|
36 /** |
|
37 * @var Zend_Cache_Manager |
|
38 */ |
|
39 protected $_manager = null; |
|
40 |
|
41 /** |
|
42 * Initialize Cache_Manager |
|
43 * |
|
44 * @return Zend_Cache_Manager |
|
45 */ |
|
46 public function init() |
|
47 { |
|
48 return $this->getCacheManager(); |
|
49 } |
|
50 |
|
51 /** |
|
52 * Retrieve Zend_Cache_Manager instance |
|
53 * |
|
54 * @return Zend_Cache_Manager |
|
55 */ |
|
56 public function getCacheManager() |
|
57 { |
|
58 if (null === $this->_manager) { |
|
59 $this->_manager = new Zend_Cache_Manager; |
|
60 |
|
61 $options = $this->getOptions(); |
|
62 foreach ($options as $key => $value) { |
|
63 if ($this->_manager->hasCacheTemplate($key)) { |
|
64 $this->_manager->setTemplateOptions($key, $value); |
|
65 } else { |
|
66 $this->_manager->setCacheTemplate($key, $value); |
|
67 } |
|
68 } |
|
69 } |
|
70 |
|
71 return $this->_manager; |
|
72 } |
|
73 } |