/** * Delete all keys from the cache * * @param bool $check If true no deletes will occur and instead CakePHP will rely * on key TTL values. * @return bool True if the cache was successfully cleared, false otherwise */ public function clear($check) { if ($check) { return true; } $keys = $this->_Memcached->getAllKeys(); foreach ($keys as $key) { if (strpos($key, $this->settings['prefix']) === 0) { $this->_Memcached->delete($key); } } return true; }
/** * Delete all cache entries. * * Beware of using this method when * using shared memory cache systems, as it will wipe every * entry within the system for all clients. * * // Delete all cache entries in the default group * Cache::instance('memcached')->delete_all(); * * @return boolean */ public function delete_all($filter = FALSE) { if ($filter === FALSE) { $result = $this->_memcached->flush(); // We must sleep after flushing, or overwriting will not work! // @see http://php.net/manual/en/function.memcached-flush.php#81420 sleep(1); return $result; } else { $keys = $this->_memcached->getAllKeys(); foreach ($keys as $key) { if (strpos($key, $filter) === 0) { $this->_memcached->delete($key); } } } }