本文整理汇总了PHP中Zend_Cache::test方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Cache::test方法的具体用法?PHP Zend_Cache::test怎么用?PHP Zend_Cache::test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Cache
的用法示例。
在下文中一共展示了Zend_Cache::test方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jsAction
/**
* Минификация яваскриптов
*
* @return void
*/
public function jsAction()
{
$this->_response->setHeader('Content-Type', 'text/javascript', true);
if (isset($this->_params['files'])) {
$files = explode(',', $this->_params['files']);
foreach ($files as $key => $file) {
$file = $this->_jsdir . trim($file) . '.js';
if (file_exists($file)) {
$files[$key] = $file;
}
}
if (!empty($files)) {
$cacheid = 'minify_js_' . md5(implode(',', $files));
$this->_cache->setMasterFiles($files);
if ($this->_cache->test($cacheid)) {
$this->_response->setBody($this->_cache->load($cacheid));
} else {
require_once 'Phorm/Plugin/jsmin.php';
$str = '';
foreach ($files as $file) {
$str .= file_get_contents($file) . PHP_EOL;
}
$js = JSMin::minify($str);
$this->_cache->save($js, $cacheid);
$this->_response->setBody($js);
}
}
}
}
示例2: get
/** Perform a curl request based on url provided
* @access public
* @param string $method
* @param array $params
* @return type
*/
public function get($method, $params)
{
$url = $this->createUrl($method, $params);
if (!$this->_cache->test(md5($url))) {
$config = array('adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_POST => true, CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"], CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_LOW_SPEED_TIME => 1));
$client = new Zend_Http_Client($url, $config);
$response = $client->request();
$data = $response->getBody();
$this->_cache->save($data);
} else {
$data = $this->_cache->load(md5($url));
}
return Zend_Json_Decoder::decode($data, Zend_Json::TYPE_OBJECT);
}
示例3: getData
/** Get data from the endpoint
* @access protected
* @return string
*/
protected function getData()
{
$key = md5($this->_uri);
if (!$this->_cache->test($key)) {
$graph = new EasyRdf_Graph(self::URI . $this->_uri . self::SUFFIX);
$graph->load();
$data = $graph->resource(self::URI . $this->_uri);
$this->_cache->save($data);
} else {
$data = $this->_cache->load($key);
}
EasyRdf_Namespace::set('dcterms', 'http://purl.org/dc/terms/');
EasyRdf_Namespace::set('pleiades', 'http://pleiades.stoa.org/places/vocab#');
return $data;
}
示例4: getData
/** Get the data for a postcode
* @access public
* @param string $postcode
* @return array
* @throws Pas_Geo_Exception
*/
public function getData($postcode)
{
if ($this->_validator->isValid($postcode)) {
$postcode = str_replace(' ', '', $postcode);
} else {
throw new Pas_Geo_Exception('Invalid postcode sent');
}
$key = md5($postcode);
if (!$this->_cache->test($key)) {
$response = $this->_get($postcode);
$this->_cache->save($response);
} else {
$response = $this->_cache->load($key);
}
$geo = json_decode($response);
return array('lat' => $geo->wgs84_lat, 'lon' => $geo->wgs84_lon);
}
示例5: fetchRow
/** Fetch one result
* @access public
* @param array $where
* @param string $order
* @return Object
*/
public function fetchRow($where = null, $order = null)
{
$id = md5($where->__toString());
if (!$this->_cache->test($id) || !$this->cache_result) {
$result = parent::fetchRow($where, $order);
$this->_cache->save($result);
return $result;
} else {
return $this->_cache->load($id);
}
}
示例6: fetchPairs
/** Fetch pairs from the model
* @access public
* @param string $sql
* @param array $bind
* @return array
*/
public function fetchPairs($sql, $bind = array())
{
$id = md5($sql);
if (!$this->_cache->test($id) || !$this->cache_result) {
$result = parent::fetchPairs($sql, $bind);
$this->_cache->save($result);
return $result;
} else {
return $this->_cache->load($id);
}
}
示例7: test
/**
* Test if a cache is available for the given id
*
* @param string $id Cache ID
* @return boolean
* @throws coding_exception
*/
public function test($id)
{
if ($this->cache === false) {
return false;
}
try {
return $this->cache->test($id);
} catch (Zend_Cache_Exception $e) {
throw new coding_exception('Zend Cache Error: ' . $e->getMessage());
}
}
示例8: getPlace
/** Get a place from the WOEID
* @access public
* @param integer $woeid
* @return boolean|array
*/
public function getPlace($woeid)
{
if (!is_null($woeid)) {
$key = 'geoplaceID' . $woeid;
if (!$this->_cache->test($key)) {
$yql = 'select * from geo.places where woeid = ' . $woeid;
$place = $this->_oauth->execute($yql, $this->_accessToken, $this->_accessSecret, $this->_accessExpiry, $this->_handle);
$this->_cache->save($place);
} else {
$place = $this->_cache->load($key);
}
return $this->_parser->parsePlace($place);
} else {
return false;
}
}