要禁用缓存对象获取或保存到缓存,您可以将选项设置caching
为false
.
使用您的对象,您可以执行以下操作:
$cacheObj = Zend_Registry::get('cacheObj');
if ($cacheObj instanceof Zend_Cache_Core) {
$cacheObj->setOption('caching', false);
}
要使其自动化,您可以编写一个控制器插件来为您执行此操作。这是一个例子:
<?php
class Application_Plugin_DisableCache extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName();
// change 'dont_cache_me' to the module you want to disable caching in
if ('dont_cache_me' == $module) {
$cacheObj = Zend_Registry::get('cacheObj');
if ($cacheObj instanceof Zend_Cache_Core) {
$cacheObj->setOption('caching', false);
}
}
}
}