@@ -116,36 +116,41 @@ public function preDispatch()
116
116
parent ::preDispatch ();
117
117
if (!$ this ->isDebug ())
118
118
{
119
- $ frontendOptions = array (
120
- 'lifetime ' => 86400 ,
121
- 'automatic_serialization ' => true
122
- );
123
-
124
- $ backendOptions = array (
125
- 'cache_dir ' => UtilityComponent::getCacheDirectory ().'/db '
126
- );
127
-
128
- $ cache = Zend_Cache::factory ('Core ' ,
129
- 'File ' ,
130
- $ frontendOptions ,
131
- $ backendOptions );
132
-
133
- // Passing the object to cache by default
134
- Zend_Db_Table_Abstract::setDefaultMetadataCache ($ cache );
119
+ $ frontendOptions = array ('automatic_serialization ' => true , 'lifetime ' => 86400 );
120
+ if (extension_loaded ('memcache ' ))
121
+ {
122
+ $ cache = Zend_Cache::factory ('Core ' , 'Memcached ' , $ frontendOptions , array ());
123
+ }
124
+ else if (extension_loaded ('memcached ' ))
125
+ {
126
+ $ cache = Zend_Cache::factory ('Core ' , 'Libmemcached ' , $ frontendOptions , array ());
127
+ }
128
+ else
129
+ {
130
+ $ cacheDir = UtilityComponent::getCacheDirectory () . '/db ' ;
131
+ if (is_writable ($ cacheDir ))
132
+ {
133
+ $ backendOptions = array ('cache_dir ' => $ cacheDir );
134
+ $ cache = Zend_Cache::factory ('Core ' , 'File ' , $ frontendOptions , $ backendOptions );
135
+ }
136
+ }
137
+ if (isset ($ cache ))
138
+ {
139
+ Zend_Db_Table_Abstract::setDefaultMetadataCache ($ cache );
140
+ }
135
141
}
136
142
}
137
143
138
144
/**
139
145
* Post-dispatch routines
140
146
*
141
- * Common usages for postDispatch() include rendering content in a sitewide
147
+ * Common usages for postDispatch() include rendering content in a site wide
142
148
* template, link url correction, setting headers, etc.
143
149
*
144
150
* @return void
145
151
*/
146
152
public function postDispatch ()
147
153
{
148
-
149
154
parent ::postDispatch ();
150
155
if ($ this ->isDebug () && $ this ->getEnvironment () != 'testing ' )
151
156
{
0 commit comments