本文整理汇总了PHP中storage::gethandle方法的典型用法代码示例。如果您正苦于以下问题:PHP storage::gethandle方法的具体用法?PHP storage::gethandle怎么用?PHP storage::gethandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storage
的用法示例。
在下文中一共展示了storage::gethandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* 获取内容并输出
* 如果stroage里面不存在,则从URL里面获取
* */
private function handle($filename, $key, $delete = false, $direct = false)
{
$content = '';
if ($this->succeed) {
$storage = storage::gethandle();
if ($delete) {
if (!$storage->exists($key)) {
die(json_encode(array('purge' => $filename, 'key' => $key, 'success' => 'not exists')));
}
$return = $storage->delete($key);
die(json_encode(array('purge' => $filename, 'key' => $key, 'success' => $return)));
}
if ($storage->exists($key) && !$direct) {
if (!NO_LOCATE && ($url = $storage->url($key))) {
$this->locate($url);
}
$content = $storage->read($key);
$this->hit = $key;
if (empty($content)) {
$this->succeed = false;
$this->error_type = 'empty_conent';
}
} else {
//$content = @file_get_contents(BASE_URL.$filename);
$content = lib::fetch_url(BASE_URL . $filename);
if (!is_array($content) || count($content) < 2) {
$this->succeed = false;
$this->error_type = 'fetch_error';
} elseif ($content[0] == 200) {
//返回200,才写入
if (!$direct) {
$storage->write($key, $content[1]);
}
} else {
header('HTTP/1.1 ' . $content[0]);
}
$content = $content[1];
}
}
//显示内容
$this->render($content);
}