【发布时间】:2013-07-10 23:02:43
【问题描述】:
我在 PHP 中使用 memcache,但我正在努力处理它向我抛出的错误。
我使用 addServer 方法添加服务器,但在生产过程中,有时我没有打开它,显然无法建立连接。这一切都在意料之中,但我收到的通知不是异常,而是我无法下车。
注意:MemcachePool::set(): 服务器 192.168.1.2 (tcp 11211, udp 0) 失败:连接尝试失败,因为连接方 一段时间后没有正确响应,或建立 连接失败,因为连接的主机没有响应。 (10060)
如何捕捉/处理此通知/错误?
【问题讨论】:
-
您可以设置error_reporting级别来关闭通知。你可以在语句前加上
@ -
try { $this->cache = Cache::instance(); } catch (Kohana_Exception $e) { Kohana::config_set('cache.default.driver', 'file'); $this->cache = Cache::instance(); }
标签: php error-handling memcached