Ignoring Server Down Error Message when using Yii

2019-09-03 10:34发布

问题:

I've enabling yii memcached, How do I ignoring this error when dedicated memcached server was down.

MemcachePool::get(): Server 192.168.1.200 (tcp 11211, udp 0) failed with: No connection could be made because the target machine actively refused it. (10061)

Thanks,

回答1:

You could:

  1. extend CMemCache as your own caching component
  2. override the getters and setters to return false if no connection is present or connection isn't active, otherwise call the parent:: equivalent method (with any necessary parameters passed)
  3. configure the application component cache to use your newly extended version of CMemCache