diff --git a/cache/stores/memcached/lib.php b/cache/stores/memcached/lib.php index 9ecb706b023..84ec315fc6c 100644 --- a/cache/stores/memcached/lib.php +++ b/cache/stores/memcached/lib.php @@ -508,9 +508,14 @@ class cachestore_memcached extends cache_store implements cache_is_configurable * @return array */ protected static function get_prefixed_keys(Memcached $connection, $prefix) { + $connkeys = $connection->getAllKeys(); + if (empty($connkeys)) { + return array(); + } + $keys = array(); $start = strlen($prefix); - foreach ($connection->getAllKeys() as $key) { + foreach ($connkeys as $key) { if (strpos($key, $prefix) === 0) { $keys[] = substr($key, $start); }