My function
CacheDInteractive... is better than try to connect to the server in each function...
PHP Code:
function CacheDInteractive($buf) {
$fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5);
$rs = "x";
if (!$fp) die("Error conectando con CacheD: [Server OFF?]");
fwrite($fp, pack("s", (strlen($buf)+2)).$buf);
$len = unpack("v", fread($fp, 2));
$rid = unpack("c", fread($fp, 1));
for ($i = 0; $i < (($len[1]-4) / 4); $i++) {
$read = unpack("i", fread($fp, 4));
$rs .= $read[1];
}
fclose($fp);
return($rs);
}