【问题标题】:Memcache produces notice unstoppableMemcache 产生不可阻挡的通知
【发布时间】: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


【解决方案1】:

您可以使用custom error handler,这样您就可以在它发生时捕捉到通知并适当地处理它,或者在执行 addServer() 并在那里处理失败的连接后检查连接是否正常。为此,请查看文档中的 this comment

【讨论】:

    猜你喜欢
    • 2023-03-23
    • 2013-02-17
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多