--- MemCachedClient.inc.php 2003-07-27 22:12:15.000000000 +0100
+++ MemCachedClient.inc.php 2003-07-27 22:08:31.000000000 +0100
@@ -267,10 +267,11 @@
$host = $this->buckets[$hv % $this->bucketcount];
$sock = $this->sock_to_host($host);
- if($sock)
+ if(is_resource($sock))
return $sock;
$hv += $this->_hashfunc($tries);
+ $tries++;
}
return null;
@@ -298,9 +299,12 @@
}
$len = strlen($val);
+ if (!is_int($exptime))
+ $exptime = 0;
// send off the request
$cmd = "$cmdname $key $flags $exptime $len\r\n$val\r\n";
+# echo "
Command is: $cmd
\n";
$cmd_len = strlen($cmd);
$offset = 0;
@@ -308,7 +312,8 @@
$offset += socket_write($sock, substr($cmd, $offset, MC_BUFFER_SZ), MC_BUFFER_SZ);
// now read the server's response
- if(socket_read($sock, 6, PHP_NORMAL_READ) == "STORED")
+ $l_szResponse = socket_read($sock, 6, PHP_NORMAL_READ);
+ if($l_szResponse == "STORED")
{
if($this->debug)
print "MemCache: $cmdname $key = $raw_val\n";
@@ -318,7 +323,7 @@
else
{
if($this->debug)
- print "_set(): Did not receive STORED as the server response!\r\n";
+ print "_set(): Did not receive STORED as the server response!\r\n; received $l_szResponse instead";
}
return 0;