} } else { throw new PermissionDeniedException("No access key passed. Access denied."); } } /********************************************************* * Parse/validate our arguments and run the specified action. *********************************************************/ if (!isset($_GET['action'])) { throw new UnknownActionException('No action specified.'); } if (SHOW_TIMERS) { $start = microtime(); } // Add our proxy to the cache-key in case we are limiting attributes based on it $cacheKey = getCacheKey($_GET, $proxy); $xmlString = apc_fetch($cacheKey); if ($xmlString === false) { // If we are being proxied, limit the the attributes to those allowed to // be passed to the proxying application. As defined in the CAS Protocol // http://www.jasig.org/cas/protocol // The first proxy listed is the most recent in the request chain. Limit // to that services' allowed attributes. if (isset($proxy)) { if (!isset($servicesDSN)) { throw new Exception('No $servicesDSN specified.'); } if (!isset($servicesUser)) { throw new Exception('No $servicesUser specified.'); } if (!isset($servicesPassword)) {
/** * Answer an XML string for a given result-array, params, and proxy * * @param array $results * @param array $params Parameters in this request to key off of. * @param optional string $proxy A proxy that we might be limiting results for. * @param optional boolean $hasMore If true, a more_result_pages='true' attribute * will be added to the response. * @return string * @access public * @since 7/31/09 */ function getResultXml(array $results, array $params, $proxy = null, $hasMore = false) { $printer = new DomXmlPrinter(); if ($hasMore) { $printer->morePagesAvailable(); } $xmlString = $printer->getOutput($results); $pageCacheKey = getCacheKey($params, $proxy); apc_store($pageCacheKey, $xmlString, RESULT_CACHE_TTL); return $xmlString; }
<?php $filterArr = array('cate1' => '11', 'cate3' => '924', 'filters' => array(), 'orders' => array(), 'perpage' => 20); $memKey = getCacheKey($filterArr); $memKeys = array($memKey); $config = array('172.17.16.105', 22122); $memObj = new Memcached(); $memObj->addServer($config[0], $config[1], false); $memRs = $memObj->getMulti($memKeys); var_dump($memRs); exit; function getCacheKey($filterArr) { if (empty($filterArr)) { return ''; } if (!isset($filterArr['filters']) || !isset($filterArr['orders'])) { return ''; } if (!is_array($filterArr['filters'])) { return ''; } if (!is_array($filterArr['orders'])) { return ''; } if (!isset($filterArr['cate3']) || $filterArr['cate3'] < 1) { return ''; } $keysArr = array(); $keysArr = getFilterKey($keysArr, $filterArr); $keysArr = getOrderKey($keysArr, $filterArr);