To my knowledge it won't trigger an exception on connection failure,
because it really shouldn't. If memcache isn't present, your
application shouldn't stop executing. Lets say you had 2 memcache
servers. One of them dies off, so "half" of your keys will get a
miss. Its better for your application to gracefully accept those
failures and just hit your datastore directly. Note, I put half in
quotes on purposes because its not really half :P
Also, I wouldn't use pconnect(). It just won't scale in PHP. You
should use addserver().
On Jul 6, 2009, at 5:45 AM, lycoch wrote:
hello all,
here is my construtor for a personnal PHP Class:
function CacheMemory($online,$host,$port){
$this->host=$host;
$this->port=$port;
$this->prefix='aws';
if($online){
try{
$this->memcache = new Memcache;
$this->memcacheEnabled=$this->memcache->pconnect($this->host,
$this->port);
}catch(Exception $e){
$this->memcacheEnabled=false;
//echo $e->getMessage();
}
}else{
$this->memcacheEnabled=false;
}
}
In my main application i use an error Handler.
The problem is that sometimes i've got:
Date : 2009-07-06 12:26:08 UTC
Error type : E_WARNING
Error text : Memcache::pconnect(): Can't connect to 195.xx.xx.xxx:
11211, Unknown error (0)
File : inc/libs/CacheMemory.php
Line : 18
I don't want that the ErrorHandler to be notified when the MC connot
connect.
Isn't what the try/catch is suppose to do ?
best regards and thanks for any help