@@ -30,7 +30,7 @@ protected function _initDoctype()
30
30
$ this ->bootstrap ('view ' );
31
31
32
32
/** @var Zend_View $view */
33
- $ view = $ this ->getResource ('view ' );
33
+ $ view = $ this ->getResource ('View ' );
34
34
$ view ->doctype ('XHTML1_STRICT ' );
35
35
}
36
36
@@ -109,6 +109,45 @@ protected function _initDatabase()
109
109
return false ;
110
110
}
111
111
112
+ /**
113
+ * Initialize the cache.
114
+ *
115
+ * @return false|Zend_Cache_Core
116
+ */
117
+ protected function _initCache ()
118
+ {
119
+ $ this ->bootstrap ('Config ' , 'Database ' );
120
+
121
+ if (Zend_Registry::get ('configGlobal ' )->get ('environment ' , 'production ' ) === 'production ' ) {
122
+ $ frontendOptions = array (
123
+ 'automatic_serialization ' => true ,
124
+ 'lifetime ' => 86400 ,
125
+ 'cache_id_prefix ' => 'midas_ ' ,
126
+ );
127
+
128
+ if (extension_loaded ('memcached ' ) || session_save_path () === 'Memcache ' ) {
129
+ $ cache = Zend_Cache::factory ('Core ' , 'Libmemcached ' , $ frontendOptions , array ());
130
+ } elseif (extension_loaded ('memcache ' )) {
131
+ $ cache = Zend_Cache::factory ('Core ' , 'Memcached ' , $ frontendOptions , array ());
132
+ } else {
133
+ $ cacheDir = UtilityComponent::getCacheDirectory ().'/db ' ;
134
+
135
+ if (is_dir ($ cacheDir ) && is_writable ($ cacheDir )) {
136
+ $ backendOptions = array ('cache_dir ' => $ cacheDir );
137
+ $ cache = Zend_Cache::factory ('Core ' , 'File ' , $ frontendOptions , $ backendOptions );
138
+ }
139
+ }
140
+
141
+ if ($ cache !== false ) {
142
+ Zend_Db_Table_Abstract::setDefaultMetadataCache ($ cache );
143
+ }
144
+ }
145
+
146
+ Zend_Registry::set ('cache ' , $ cache );
147
+
148
+ return $ cache ;
149
+ }
150
+
112
151
/** Initialize the error handler. */
113
152
protected function _initErrorHandle ()
114
153
{
@@ -132,7 +171,7 @@ protected function _initErrorHandle()
132
171
*/
133
172
protected function _initInternationalization ()
134
173
{
135
- $ this ->bootstrap (array ('Config ' , 'Database ' , 'FrontController ' ));
174
+ $ this ->bootstrap (array ('Cache ' , ' Config ' , 'Database ' , 'FrontController ' ));
136
175
137
176
/** @var false|Zend_Db_Adapter_Abstract $database */
138
177
$ database = $ this ->getResource ('Database ' );
@@ -343,7 +382,7 @@ protected function _initSass()
343
382
*/
344
383
protected function _initRouter ()
345
384
{
346
- $ this ->bootstrap (array ('Config ' , 'Database ' , 'FrontController ' ));
385
+ $ this ->bootstrap (array ('Cache ' , ' Config ' , 'Database ' , 'FrontController ' ));
347
386
348
387
/** @var Zend_Controller_Front $frontController */
349
388
$ frontController = $ this ->getResource ('FrontController ' );
0 commit comments