function call($method, $args = NULL)
{
+ $memcache = new Memcache;
+ $memcache->connect($this->server, 11211) or die ("Could not connect");
+
+ $key = $method;
+ if (gettype($args[1]) == "array")
+ {
+ foreach(array_values($args[1]) as $arg)
+ $key .= $arg;
+ }
+ else
+ $key .= $args[1];
+
+ $result = $memcache->get($key);
+ if ($result != FALSE) {
+ if ($result == "NULL")
+ return NULL;
+ if (gettype($result) == "array")
+ return $result;
+ else
+ return unserialize($result);
+ }
+
if ($this->multicall) {
$this->calls[] = array ('methodName' => $method,
'params' => $args);
return NULL;
} else {
- return $this->internal_call ($method, $args, 3);
+ $result = $this->internal_call ($method, $args, 3);
+ if ($result == NULL)
+ $result = "NULL";
+ $memcache->set($key, $result, false, 500);
+ return $result;
}
}