Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Caching Server Definitions Between Requests

Attaching many classes to an XML-RPC server instance can utilize a lot of resources; each class must introspect using the Reflection API (via Zend_Server_Reflection), which in turn generates a list of all possible method signatures to provide to the server class.

To reduce this performance hit somewhat, Zend_XmlRpc_Server_Cache can be used to cache the server definition between requests. When combined with __autoload(), this can greatly increase performance.

An sample usage follows:

function __autoload($class)

$cacheFile dirname(__FILE__) . '/xmlrpc.cache';
$server = new Zend_XmlRpc_Server();

if (!
Zend_XmlRpc_Server_Cache::get($cacheFile$server)) {

$server->setClass('My_Services_Glue''glue');   // glue. namespace
$server->setClass('My_Services_Paste''paste'); // paste. namespace
$server->setClass('My_Services_Tape''tape');   // tape. namespace



The above example attempts to retrieve a server definition from xmlrpc.cache in the same directory as the script. If unsuccessful, it loads the service classes it needs, attaches them to the server instance, and then attempts to create a new cache file with the server definition.

Zend Framework