/** * Clean some cache records * * Available modes are : * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) * This mode is not supported in this backend * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags * ($tags can be an array of strings or a single string) * This mode is not supported in this backend * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not matching one of the given tags * ($tags can be an array of strings or a single string) * This mode is not supported in this backend * * @param string $mode clean mode * @param tags array $tags array of tags * @return boolean true if no problem */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_TAG) { $idlist = null; foreach ($tags as $tag) { $next_idlist = output_cache_get(self::TAGS_PREFIX . $tag, $this->_directives['lifetime']); if ($idlist) { $idlist = array_intersect_assoc($idlist, $next_idlist); } else { $idlist = $next_idlist; } if (count($idlist) == 0) { // if ID list is already empty - we may skip checking other IDs $idlist = null; break; } } if ($idlist) { foreach ($idlist as $id) { output_cache_remove_key($id); } } return true; } if ($mode == Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG) { $this->_log("Zend_Cache_Backend_ZendPlatform::clean() : CLEANING_MODE_NOT_MATCHING_TAG is not supported by the Zend Platform backend"); } $cache_dir = ini_get('zend_accelerator.output_cache_dir'); if (!$cache_dir) { return false; } $cache_dir .= '/.php_cache_api/'; return $this->_clean($cache_dir, $mode); }
/** * Remove a cache file. * * @return void */ public function remove() { output_cache_remove_key($this->getIdMd5()); return; }
function __unset($key) { parent::__unset($key); output_cache_remove_key($this->_realKey($key)); }
/** * Clean some cache records * * Available modes are : * IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) * IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) * This mode is not supported in this backend * IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags * ($tags can be an array of strings or a single string) * IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => unsupported * IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags * ($tags can be an array of strings or a single string) * * @param string $mode Clean mode * @param array $tags Array of tags * @throws IfwPsn_Vendor_Zend_Cache_Exception * @return boolean True if no problem */ public function clean($mode = IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { switch ($mode) { case IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_ALL: case IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_OLD: $cache_dir = ini_get('zend_accelerator.output_cache_dir'); if (!$cache_dir) { return false; } $cache_dir .= '/.php_cache_api/'; return $this->_clean($cache_dir, $mode); break; case IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_MATCHING_TAG: $idlist = null; foreach ($tags as $tag) { $next_idlist = output_cache_get(self::TAGS_PREFIX . $tag, $this->_directives['lifetime']); if ($idlist) { $idlist = array_intersect_assoc($idlist, $next_idlist); } else { $idlist = $next_idlist; } if (count($idlist) == 0) { // if ID list is already empty - we may skip checking other IDs $idlist = null; break; } } if ($idlist) { foreach ($idlist as $id) { output_cache_remove_key($id); } } return true; break; case IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: $this->_log("IfwPsn_Vendor_Zend_Cache_Backend_ZendPlatform::clean() : CLEANING_MODE_NOT_MATCHING_TAG is not supported by the Zend Platform backend"); return false; break; case IfwPsn_Vendor_Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $idlist = null; foreach ($tags as $tag) { $next_idlist = output_cache_get(self::TAGS_PREFIX . $tag, $this->_directives['lifetime']); if ($idlist) { $idlist = array_merge_recursive($idlist, $next_idlist); } else { $idlist = $next_idlist; } if (count($idlist) == 0) { // if ID list is already empty - we may skip checking other IDs $idlist = null; break; } } if ($idlist) { foreach ($idlist as $id) { output_cache_remove_key($id); } } return true; break; default: IfwPsn_Vendor_Zend_Cache::throwException('Invalid mode for clean() method'); break; } }
/** * Clean some cache records * * Available modes are : * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) * This mode is not supported in this backend * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags * ($tags can be an array of strings or a single string) * This mode is not supported in this backend * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not matching one of the given tags * ($tags can be an array of strings or a single string) * This mode is not supported in this backend * * @param string $mode clean mode * @param tags array $tags array of tags * @return boolean true if no problem */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_TAG) { foreach ($tags as $tag) { $idlist = output_cache_get(self::TAGS_PREFIX . $tag); if ($idlist) { foreach ($idlist as $id) { output_cache_remove_key($id); } } } return true; } if ($mode == Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG) { if ($this->_directives['logging']) { Zend_Log::log("Zend_Cache_Backend_ZendPlatform::clean() : CLEANING_MODE_NOT_MATCHING_TAG is not supported by the Zend Platform backend", Zend_Log::LEVEL_WARNING); } } $cacheDir = ini_get('zend_accelerator.output_cache_dir'); if (!$cacheDir) { return false; } $cacheDir .= '/.php_cache_api/'; return $this->_clean($cacheDir, $mode); }
/** * Clear a key from the cache. This is used to invalidate a single key. * * @param String $key -- Key from global namespace */ function sugar_cache_clear($key) { unset($GLOBALS['cache_local_store'][$key]); if ($GLOBALS['external_cache_enabled']) { $external_key = $GLOBALS['sugar_config']['unique_key'] . $key; if ($GLOBALS['external_cache_type'] == 'zend') { output_cache_remove_key($external_key); } elseif ($GLOBALS['external_cache_type'] == 'apc') { apc_delete($external_key); } } }