_log("Zend_Cache_Backend_Apc::load() : \$doNotTestCacheValidity=true is unsupported by the Apc backend"); } $tmp = apc_fetch($id); if (is_array($tmp)) { return $tmp[0]; } return false; } /** * Test if a cache is available or not (for the given id) * * @param string $id cache id * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record */ public function test($id) { $tmp = apc_fetch($id); if (is_array($tmp)) { return $tmp[1]; } return false; } /** * Save some string datas into a cache record * * Note : $data is always "string" (serialization is done by the * core not by the backend) * * @param string $data datas to cache * @param string $id cache id * @param array $tags array of strings, the cache record will be tagged by each string entry * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime) * @return boolean true if no problem */ public function save($data, $id, $tags = array(), $specificLifetime = false) { $lifetime = $this->getLifetime($specificLifetime); $result = apc_store($id, array($data, time()), $lifetime); if (count($tags) > 0) { $this->_log("Zend_Cache_Backend_Apc::save() : tags are unsupported by the Apc backend"); } return $result; } /** * Remove a cache record * * @param string $id cache id * @return boolean true if no problem */ public function remove($id) { return apc_delete($id); } /** * Clean some cache records * * Available modes are : * 'all' (default) => remove all cache entries ($tags is not used) * 'old' => remove too old cache entries ($tags is not used) * 'matchingTag' => remove cache entries matching all given tags * ($tags can be an array of strings or a single string) * 'notMatchingTag' => remove cache entries not matching one of the given tags * ($tags can be an array of strings or a single string) * * @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_ALL) { return apc_clear_cache('user'); } if ($mode==Zend_Cache::CLEANING_MODE_OLD) { $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend"); } if ($mode==Zend_Cache::CLEANING_MODE_MATCHING_TAG) { $this->_log("Zend_Cache_Backend_Apc::clean() : tags are unsupported by the Apc backend"); } if ($mode==Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG) { $this->_log("Zend_Cache_Backend_Apc::clean() : tags are unsupported by the Apc backend"); } } /** * Return true if the automatic cleaning is available for the backend * * @return boolean */ public function isAutomaticCleaningAvailable() { return false; } }