Lines 76-82
Link Here
|
76 |
|
76 |
|
77 |
$sock = $this->get_sock($key); |
77 |
$sock = $this->get_sock($key); |
78 |
|
78 |
|
79 |
if(!$sock) |
79 |
if(! is_resource($sock)) |
80 |
return 0; |
80 |
return 0; |
81 |
|
81 |
|
82 |
if(is_array($key)) |
82 |
if(is_array($key)) |
Lines 134-139
Link Here
|
134 |
// like get() but takes an array of keys |
134 |
// like get() but takes an array of keys |
135 |
function get_multi($keys) |
135 |
function get_multi($keys) |
136 |
{ |
136 |
{ |
|
|
137 |
$socks = array(); |
138 |
|
137 |
if(!$this->active) |
139 |
if(!$this->active) |
138 |
return null; |
140 |
return null; |
139 |
|
141 |
|
Lines 147-153
Link Here
|
147 |
{ |
149 |
{ |
148 |
$sock = $this->get_sock($k); |
150 |
$sock = $this->get_sock($k); |
149 |
|
151 |
|
150 |
if($sock) |
152 |
if(is_resource($sock)) |
151 |
{ |
153 |
{ |
152 |
$k = is_array($k) ? $k[1] : $k; |
154 |
$k = is_array($k) ? $k[1] : $k; |
153 |
|
155 |
|
Lines 267-273
Link Here
|
267 |
$host = $this->buckets[$hv % $this->bucketcount]; |
269 |
$host = $this->buckets[$hv % $this->bucketcount]; |
268 |
$sock = $this->sock_to_host($host); |
270 |
$sock = $this->sock_to_host($host); |
269 |
|
271 |
|
270 |
if($sock) |
272 |
if(is_resource($sock)) |
271 |
return $sock; |
273 |
return $sock; |
272 |
|
274 |
|
273 |
$hv += $this->_hashfunc($tries); |
275 |
$hv += $this->_hashfunc($tries); |
Lines 284-290
Link Here
|
284 |
return 0; |
286 |
return 0; |
285 |
|
287 |
|
286 |
$sock = $this->get_sock($key); |
288 |
$sock = $this->get_sock($key); |
287 |
if(!$sock) |
289 |
if(!is_resource($sock)) |
288 |
return 0; |
290 |
return 0; |
289 |
|
291 |
|
290 |
$flags = 0; |
292 |
$flags = 0; |
Lines 298-306
Link Here
|
298 |
} |
300 |
} |
299 |
|
301 |
|
300 |
$len = strlen($val); |
302 |
$len = strlen($val); |
|
|
303 |
if (!is_int($exptime)) |
304 |
$exptime = 0; |
301 |
|
305 |
|
302 |
// send off the request |
306 |
// send off the request |
303 |
$cmd = "$cmdname $key $flags $exptime $len\r\n$val\r\n"; |
307 |
$cmd = "$cmdname $key $flags $exptime $len\r\n$val\r\n"; |
|
|
308 |
# echo "<br>Command is: $cmd<br>\n"; |
304 |
$cmd_len = strlen($cmd); |
309 |
$cmd_len = strlen($cmd); |
305 |
$offset = 0; |
310 |
$offset = 0; |
306 |
|
311 |
|
Lines 308-314
Link Here
|
308 |
$offset += socket_write($sock, substr($cmd, $offset, MC_BUFFER_SZ), MC_BUFFER_SZ); |
313 |
$offset += socket_write($sock, substr($cmd, $offset, MC_BUFFER_SZ), MC_BUFFER_SZ); |
309 |
|
314 |
|
310 |
// now read the server's response |
315 |
// now read the server's response |
311 |
if(socket_read($sock, 6, PHP_NORMAL_READ) == "STORED") |
316 |
$l_szResponse = socket_read($sock, 30, PHP_NORMAL_READ); |
|
|
317 |
# echo $l_szResponse . "<br>\n"; |
318 |
if($l_szResponse == "STORED") |
312 |
{ |
319 |
{ |
313 |
if($this->debug) |
320 |
if($this->debug) |
314 |
print "MemCache: $cmdname $key = $raw_val\n"; |
321 |
print "MemCache: $cmdname $key = $raw_val\n"; |
Lines 318-324
Link Here
|
318 |
else |
325 |
else |
319 |
{ |
326 |
{ |
320 |
if($this->debug) |
327 |
if($this->debug) |
321 |
print "_set(): Did not receive STORED as the server response!\r\n"; |
328 |
print "_set(): Did not receive STORED as the server response!\r\n; received $l_szResponse instead"; |
322 |
} |
329 |
} |
323 |
|
330 |
|
324 |
return 0; |
331 |
return 0; |
Lines 344-349
Link Here
|
344 |
|
351 |
|
345 |
$cmd .="\r\n"; |
352 |
$cmd .="\r\n"; |
346 |
$cmd_len = strlen($cmd); |
353 |
$cmd_len = strlen($cmd); |
|
|
354 |
|
347 |
$offset = 0; |
355 |
$offset = 0; |
348 |
|
356 |
|
349 |
while($offset < $cmd_len) |
357 |
while($offset < $cmd_len) |