Re: Re: XML/RPC/Cached_Server ?
| From: | Stephan Schmidt | Date: | Tue, 30 Aug 2005 08:06:36 +0000 |
| Subject: | Re: Re: XML/RPC/Cached_Server ? | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-39619@lists.php.net to get a copy of this message | ||
Hi,
Fabien MARTY wrote:
With Cache/Lite/*, you can cache everything you want. But this Cached_Server is XMLRPC only because : - the "cache id" is calculated with a hash of $HTTP_RAW_POST_DATA This is not a good idea IMHO... In XML-RPC request, you may add any whitespace you want this will lead to different hashes for the same request.
- the XML request is parsed with a regexp to find the "function name" (in order to set a particular cache lifetime or not) Why don't we think about an interceptor concept for XML_RPC so you could add the caching mechanism directly in the server (just my first thoughts):class XML_RPC_Interceptor_Cache {
var $sig;
function interceptRequest($method, $params) {
$sig = md5($method . serialize($params));
$this->sig = $sig;
$result = $this->cache->get($sig);
echo $result;
// returning false will stop the request
return false;
}
function interceptResponse($response) {
$this->cache->store($sig, $response);
return true;
}
}
$cache = new XML_RPC_Interceptor_Cache();
$server = new XML_RPC_Server();
$server->addInterceptor($cache);
$server->service();
This would be a lot more transparent and flexible as you could easly add gzip support to the server, add IP-based authentication for some function or whatever you need directly in the server.
What do you think about it? Should not be very hard to add to XML_RPC2...
Stephan