Exemplo n.º 1
0
 /**
  * This method is called after {@link XOAD_Server::notifyObservers}
  * is called.
  *
  * @access	public
  *
  * @return	bool	Always true.
  *
  */
 public function updateObserver($event, $arguments)
 {
     if ($event == 'initializeCallbackSuccess') {
         if (array_key_exists('source', $arguments['request'])) {
             if (XOAD_Cache::initialize($arguments['request'])) {
                 exit;
             }
         }
     } else {
         if ($event == 'dispatchLeave') {
             if (array_key_exists('returnValue', $arguments['response'])) {
                 if (defined('XOAD_CACHE_REQUEST')) {
                     XOAD_Cache::cacheRequest($arguments['request'], $arguments['response']);
                 }
             }
         }
     }
     return true;
 }
Exemplo n.º 2
0
class Class1
{
    function invoke()
    {
        sleep(2);
    }
}
class Class2
{
    function invoke()
    {
        sleep(2);
    }
}
require_once '../../xoad.php';
XOAD_Cache::allowCaching(null, null, 10);
if (XOAD_Server::runServer()) {
    exit;
}
echo XOAD_Utilities::header('../..') . "\n";
?>
<script type="text/javascript">

var class1 = <?php 
echo XOAD_Client::register(new Class1()) . "\n";
?>
;
var class2 = <?php 
echo XOAD_Client::register(new Class2()) . "\n";
?>
;
Exemplo n.º 3
0
 /**
  * This method is called when the request matches the configurated
  * criterias for caching, but there is no data in the cache.
  *
  * @access	public
  *
  * @param	array	$request	The data that is associated with the
  *								callback.
  *
  * @param	array	$response	The data that is associated with the
  *								response.
  *
  * @return	bool	True if the request is cached, false otherwise.
  *
  * @static
  *
  */
 public static function cacheRequest(&$request, &$response)
 {
     if (!array_key_exists('_XOAD_CACHE_ARGUMENTS', $GLOBALS)) {
         return false;
     }
     $storage =& XOAD_Cache::getStorage();
     $cacheId =& $GLOBALS['_XOAD_CACHE_ARGUMENTS']['id'];
     $cacheData =& $GLOBALS['_XOAD_CACHE_ARGUMENTS']['data'];
     $cacheResponse = XOAD_Client::register($response);
     return $storage->save($cacheId, $cacheData['expire'], $cacheResponse);
 }