}
public function clear($prefix = '') {
- $prefix = $this->getNameSpace() . $prefix;
- $allKeys = self::$cache->getAllKeys();
- if ($allKeys === false) {
- // newer Memcached doesn't like getAllKeys(), flush everything
- self::$cache->flush();
- return true;
- }
- $keys = [];
- $prefixLength = strlen($prefix);
- foreach ($allKeys as $key) {
- if (substr($key, 0, $prefixLength) === $prefix) {
- $keys[] = $key;
- }
- }
- if (method_exists(self::$cache, 'deleteMulti')) {
- self::$cache->deleteMulti($keys);
- } else {
- foreach ($keys as $key) {
- self::$cache->delete($key);
- }
- }
+ // Newer Memcached doesn't like getAllKeys(), flush everything
+ self::$cache->flush();
return true;
}