/** * Delete a cache entry based on id * // Delete 'foo' entry from the apc group * Cache::instance('apc')->delete('foo'); * @param string $id id to remove from cache * @return boolean */ public function delete($id) { // for ProfilerToolbar ProfilerToolbar::cacheLog('del', array_search($this, Cache::$instances), $id); // /for ProfilerToolbar return apc_delete($this->_sanitize_id($id)); }
/** * Set a value to cache with id and lifetime * * $data = 'bar'; * * // Set 'bar' to 'foo' in default group, using default expiry * Cache::instance()->set('foo', $data); * * // Set 'bar' to 'foo' in default group for 30 seconds * Cache::instance()->set('foo', $data, 30); * * // Set 'bar' to 'foo' in memcache group for 10 minutes * if (Cache::instance('memcache')->set('foo', $data, 600)) * { * // Cache was set successfully * return * } * * @param string id of cache entry * @param string data to set to cache * @param integer lifetime in seconds * @return boolean */ public function set($id, $data, $lifetime = 3600) { // for ProfilerToolbar ProfilerToolbar::cacheLog('set', array_search($this, Cache::$instances), $id, $lifetime); // /for ProfilerToolbar return $this->memcached_instance->set($id, $data, $lifetime); }
/** * Delete a cache entry based on id * * // Delete 'foo' entry from the file group * Cache::instance('file')->delete('foo'); * * @param string id to remove from cache * @return boolean */ public function delete($id) { // for ProfilerToolbar ProfilerToolbar::cacheLog('del', array_search($this, Cache::$instances), $id); // /for ProfilerToolbar $filename = Cache_File::filename($this->_sanitize_id($id)); $directory = $this->_resolve_directory($filename); return $this->_delete_file(new SplFileInfo($directory . $filename), NULL, TRUE); }
/** * Delete a cache entry based on id * * @param string id * @param integer timeout [Optional] * @return boolean * @throws Cache_Exception */ public function delete($id) { // for ProfilerToolbar ProfilerToolbar::cacheLog('del', array_search($this, Cache::$instances), $id); // /for ProfilerToolbar // Prepare statement $statement = $this->_db->prepare('DELETE FROM caches WHERE id = :id'); // Remove the entry try { $statement->execute(array(':id' => $this->_sanitize_id($id))); } catch (PDOException $e) { throw new Cache_Exception('There was a problem querying the local SQLite3 cache. :error', array(':error' => $e->getMessage())); } return (bool) $statement->rowCount(); }
/** * Delete a cache entry based on id * // Delete the 'foo' cache entry immediately * Cache::instance('memcache')->delete('foo'); * // Delete the 'bar' cache entry after 30 seconds * Cache::instance('memcache')->delete('bar', 30); * @param string $id id of entry to delete * @param integer $timeout timeout of entry, if zero item is deleted immediately, otherwise the item will delete after the specified value in seconds * @return boolean */ public function delete($id, $timeout = 0) { // for ProfilerToolbar ProfilerToolbar::cacheLog('del', array_search($this, Cache::$instances), $id); // /for ProfilerToolbar // Delete the id return $this->_memcache->delete($this->_sanitize_id($id), $timeout); }