forked from leftypol/leftypol
MemcacheCacheDriver.php: add detailed errors
This commit is contained in:
parent
2b30929bc9
commit
7aae8be1ae
1 changed files with 8 additions and 4 deletions
|
|
@ -13,10 +13,12 @@ class MemcachedCacheDriver implements CacheDriver {
|
||||||
public function __construct(string $prefix, string $server_uri, int $server_port, int $server_weight) {
|
public function __construct(string $prefix, string $server_uri, int $server_port, int $server_weight) {
|
||||||
$this->inner = new \Memcached();
|
$this->inner = new \Memcached();
|
||||||
if (!$this->inner->setOption(\Memcached::OPT_BINARY_PROTOCOL, true)) {
|
if (!$this->inner->setOption(\Memcached::OPT_BINARY_PROTOCOL, true)) {
|
||||||
throw new \RuntimeException('Unable to set the memcached protocol!');
|
$err = $this->inner->getResultMessage();
|
||||||
|
throw new \RuntimeException("Unable to set the memcached protocol: '$err'");
|
||||||
}
|
}
|
||||||
if (!$this->inner->setOption(\Memcached::OPT_PREFIX_KEY, $prefix)) {
|
if (!$this->inner->setOption(\Memcached::OPT_PREFIX_KEY, $prefix)) {
|
||||||
throw new \RuntimeException('Unable to set the memcached prefix!');
|
$err = $this->inner->getResultMessage();
|
||||||
|
throw new \RuntimeException("Unable to set the memcached prefix: '$err'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$maybe_unix_path = self::asUnixSocketPath($server_uri);
|
$maybe_unix_path = self::asUnixSocketPath($server_uri);
|
||||||
|
|
@ -38,11 +40,13 @@ class MemcachedCacheDriver implements CacheDriver {
|
||||||
if (!$found_in_curr) {
|
if (!$found_in_curr) {
|
||||||
if (!empty($current_servers)) {
|
if (!empty($current_servers)) {
|
||||||
if ($this->inner->resetServerList()) {
|
if ($this->inner->resetServerList()) {
|
||||||
throw new \RuntimeException('Unable to reset the memcached server list!');
|
$err = $this->inner->getResultMessage();
|
||||||
|
throw new \RuntimeException("Unable to reset the memcached server list: '$err'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->inner->addServer($server_uri, $server_port, $server_weight)) {
|
if ($this->inner->addServer($server_uri, $server_port, $server_weight)) {
|
||||||
throw new \RuntimeException('Unable to add memcached servers!');
|
$err = $this->inner->getResultMessage();
|
||||||
|
throw new \RuntimeException("Unable to add memcached servers: '$err'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue