/** * Delete cahche on request. **/ function deleteCache($method) { if ($oCache = CCache::load($this)) { if ($aSetting = $oCache->getMethod($method)) { $oCache->remove($aSetting['tag']); } } }
/** * Triggered when invoking inaccessible method in an object. * **/ public function __call($methodName, $arguments) { // Cache is set in the model class. if (($oCache = CCache::load($this->oModel)) && ($aSetting = $oCache->getMethod($methodName))) { $cacheAction = $aSetting['action']; $aCacheTag = $aSetting['tag']; $oZendCache = CFactory::getCache('core'); $className = get_class($this->oModel); // Genereate cache file. if ($cacheAction == CCache::ACTION_SAVE) { if (!($data = $oZendCache->load($className . '_' . $methodName . '_' . md5(serialize($arguments))))) { $data = call_user_func_array(array($this->oModel, $methodName), $arguments); $oZendCache->save($data, NULL, $aCacheTag); } // Remove cache file. } elseif ($cacheAction == CCache::ACTION_REMOVE) { $oCache->remove($aCacheTag); $data = call_user_func_array(array($this->oModel, $methodName), $arguments); } } else { $data = call_user_func_array(array($this->oModel, $methodName), $arguments); } return $data; }