namespace Friendica\Core\Cache;
use Friendica\Core\Cache;
+use Friendica\Core\Logger;
use Exception;
-use Friendica\Network\HTTPException\InternalServerErrorException;
use Memcached;
/**
$this->memcached = new Memcached();
-
- $this->memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, false);
-
array_walk($memcached_hosts, function (&$value) {
if (is_string($value)) {
$value = array_map('trim', explode(',', $value));
*/
public function getAllKeys($prefix = null)
{
- // Doesn't work because of https://github.com/php-memcached-dev/php-memcached/issues/367
- // returns everytime an empty array
- throw new InternalServerErrorException('getAllKeys for Memcached not supported yet');
+ $keys = $this->getOriginalKeys($this->memcached->getAllKeys());
- $list = $this->getOriginalKeys($this->memcached->getAllKeys());
-
- return $this->filterPrefix($list, $prefix);
+ if ($this->memcached->getResultCode() == Memcached::RES_SUCCESS) {
+ return $this->filterArrayKeysByPrefix($keys, $prefix);
+ } else {
+ Logger::log('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), Logger::ALL);
+ return [];
+ }
}
/**
if ($this->memcached->getResultCode() === Memcached::RES_SUCCESS) {
$return = $value;
+ } else {
+ Logger::log('Memcached \'get\' failed with ' . $this->memcached->getResultMessage(), Logger::ALL);
}
return $return;
$value
);
}
-
}
/**