當前位置: 首頁>>代碼示例>>PHP>>正文


PHP helper::file_cache方法代碼示例

本文整理匯總了PHP中helper::file_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP helper::file_cache方法的具體用法?PHP helper::file_cache怎麽用?PHP helper::file_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在helper的用法示例。


在下文中一共展示了helper::file_cache方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 function __construct()
 {
     $this->dbm = new db_mysql();
     $this->table = TB_PREFIX . 'url_rewrite';
     $this->host = $_SERVER['HTTP_HOST'];
     // 偽靜態對象初始化
     $a = helper::file_cache($this->host . '_' . CACHE_PREFIX . 'url_config', '', CACHE_TIME, SITE_PATH . CACHE_NAME);
     if ($a == 'timeout') {
         $a = helper::file_cache($this->host . '_' . CACHE_PREFIX . 'url_config', $this->url_config(), CACHE_TIME, SITE_PATH . CACHE_NAME);
     }
     $this->url_config = $a;
     $this->rewrite = SITE_REWRITEURL;
     $this->root_path = SITE_PATH;
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:14,代碼來源:url_rewrite.model.php

示例2: update_cate

 /**
  * 更新分類緩存
  */
 public function update_cate()
 {
     $this->categories = helper::file_cache($this->host . '_' . CACHE_PREFIX . 'categories', $this->categories(), $this->cache_time, SITE_PATH . CACHE_NAME);
     //綁定域名的分類重寫緩存
     foreach ($this->categories as $k => $v) {
         if (substr($v['go_url'], 0, 7) == 'http://') {
             $this->set_domain($k, $v['go_url']);
         }
     }
     $this->categories = helper::file_cache($this->host . '_' . CACHE_PREFIX . 'categories', $this->categories, $this->cache_time, SITE_PATH . CACHE_NAME);
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:14,代碼來源:category.model_old.php

示例3: nlink

 /**
  * 把文檔內容替換內鏈
  * @param $content 內容
  * @param  $n 內鏈個數 默認5個
  */
 public function nlink($content, $n = 5)
 {
     $file_path = SITE_PATH . CACHE_NAME;
     $rs = helper::file_cache(CACHE_PREFIX . 'nlink', '', CACHE_TIME, $file_path);
     //讀取緩存
     if ($rs === 'timeout') {
         //緩存過期
         @unlink($file_path . '/' . CACHE_PREFIX . 'nlink');
         $sql = "SELECT * FROM " . TB_PREFIX . "nlink ORDER BY 'nlink_id' DESC LIMIT 0,2000";
         $rs = $this->dbm->query($sql);
         $rs = helper::file_cache(CACHE_PREFIX . 'nlink', $rs['list'], CACHE_TIME, $file_path);
     }
     $n = intval($n);
     $n = !empty($n) ? $n : 5;
     foreach ($rs as $v) {
         $content = preg_replace('~' . $v['nlink_txt'] . '~', '<a href="' . $v['nlink_url'] . '" target="_blank">' . $v['nlink_txt'] . '</a>', $content, 1, $count);
         $n -= $count;
         if ($n == 0) {
             break;
         }
     }
     unset($rs);
     return $content;
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:29,代碼來源:common.class.php

示例4: get_list_tag

 /**
  * 取精確標簽資訊列表
  *
  * @param  $ 為數組格式
  * @param  $ =>where          更新的條件語句
  * @param  $ =>order          排序
  * @param  $ =>pagesize       分頁大小
  * @param  $ =>p              當前頁碼
  * @param  $ =>rewrite        URL重寫方式 0,1,2,默認為2
  * @param  $ =>count          是否計算總數 0 不計算 1 計算
  * @param  $ =>resource       是否同時取出資源 0 不取 1 取
  * @param  $ =>fields       查詢的字段
  * @param  $ =>no_cache      1=強製讀取最新數據
  * @param  $ =>extern  讀取擴展表字段0=不讀取,1=讀取
  */
 public function get_list_tag($params)
 {
     $keyword_id = isset($params['keyword_id']) ? $params['keyword_id'] : '';
     $where = isset($params['where']) ? $params['where'] : '';
     $pagesize = isset($params['pagesize']) ? $params['pagesize'] : PAGESIZE_F;
     $p = isset($params['p']) ? $params['p'] : 1;
     $count = $params['count'] = isset($params['count']) ? $params['count'] : 0;
     $rewrite = isset($params['rewrite']) ? $params['rewrite'] : 2;
     $resource = isset($params['resource']) ? $params['resource'] : 0;
     $fields = isset($params['fields']) ? $params['fields'] : '';
     $node = isset($_GET['tpl']) ? $_GET['tpl'] : 'tag';
     $no_cache = isset($params['no_cache']) ? $params['no_cache'] : 0;
     $state = isset($params['state']) ? $params['state'] : 0;
     $show_extern = isset($params['extern']) ? $params['extern'] : 0;
     $show_tags = isset($params['show_tags']) ? $params['show_tags'] : 0;
     $order = 'order by b.info_id desc';
     $sql = "select * from " . TB_PREFIX . "keyword where keyword_id='" . $keyword_id . "' limit 1";
     $rs = $this->dbm->query($sql);
     $keyword = '';
     if (count($rs['list']) == 1) {
         $keyword = $rs['list'][0]['keyword'];
     }
     if ($fields == '') {
         $fields = '*';
     } else {
         $fields_arr = explode(',', $fields);
         $fields = '';
         for ($i = 0; $i < count($fields_arr); $i++) {
             $fields .= ',' . trim($fields_arr[$i]);
         }
         $fields = substr($fields, 1);
     }
     $total = 0;
     //總數
     // 拚接SQL語句
     $sql = "select * from " . TB_PREFIX . "keyword_relation as a left join " . TB_PREFIX . "info_list as b on a.info_id=b.info_id where a.keyword_id='{$keyword_id}' and b.info_state={$state} ";
     if (strlen($where) > 0) {
         $sql .= " and {$where} ";
     }
     //die($sql);
     // 拚接排序
     $suffix = $order;
     // 拚接分頁數據
     $suffix .= " limit " . ($p - 1) * $pagesize . ",{$pagesize}";
     // 緩存開啟,獲取緩存內容
     if ($no_cache == 1) {
         $result = $this->dbm->query($sql, $suffix, $count);
     } else {
         if (defined('CACHE_TIME') && CACHE_TIME != '' && CACHE_TIME != 0) {
             // 緩存文件名
             $cache_file = md5($sql . $suffix);
             $data_path = SITE_PATH . CACHE_NAME . '/list/' . substr($cache_file, 0, 2);
             // 讀取緩存
             $result = helper::file_cache($cache_file, '', CACHE_TIME, $data_path);
             if ($result == 'timeout') {
                 $result = $this->dbm->query($sql, $suffix, $count);
                 for ($i = 0; $i < count($result['list']); $i++) {
                     unset($result['list'][$i]['uid']);
                     unset($result['list'][$i]['uname']);
                 }
                 // 寫入緩存
                 $result = helper::file_cache($cache_file, $result, CACHE_TIME, $data_path);
             }
         } else {
             $result = $this->dbm->query($sql, $suffix, $count);
         }
     }
     if ($count == 1) {
         $total = $result['total'];
     } else {
         $result['total'] = $total;
     }
     $result['keyword'] = $keyword;
     if (defined('INFO_IMG') && file_exists(INFO_IMG)) {
         $default_img = INFO_IMG;
     }
     // 重寫返回數組
     for ($i = 0; $i < count($result['list']); $i++) {
         $result['list'][$i]['cate'] = $this->categories[$result['list'][$i]['last_cate_id']];
         if ($show_extern == '1') {
             // 取擴展表
             $extern = $this->get_extern_by_cate_id($result['list'][$i]['cate']['cate_id']);
             if ($extern['extern_name'] != '') {
                 $result['list'][$i]['extern'] = $this->get_extern($extern['extern_name'], $result['list'][$i]['info_id']);
             }
//.........這裏部分代碼省略.........
開發者ID:cranefly,項目名稱:crane,代碼行數:101,代碼來源:common.class.php

示例5: update_models

 /**
  * 更新模型緩存
  */
 public function update_models()
 {
     $this->models = helper::file_cache($this->host . '_' . CACHE_PREFIX . 'model', $this->get_model(), CACHE_TIME, SITE_PATH . CACHE_NAME);
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:7,代碼來源:model.model.php

示例6: cache

 function cache($params = array())
 {
     $params['cachekey'] = isset($params['cachekey']) ? $params['cachekey'] : '';
     $params['cachetime'] = isset($params['cachetime']) ? $params['cachetime'] : 3600 * 24;
     $params['type'] = isset($params['type']) ? $params['type'] : 'array';
     if ($params['cachekey'] == '') {
         return '未定義cachekey';
     }
     $cache = helper::file_cache($params['cachekey'], '', $params['cachetime']);
     if ($cache == 'timeout') {
         //echo $params['funcname']."(\$params)";
         if (preg_match('~\\(.*?\\)~', $params['funcname'])) {
             eval('$content=' . $params['funcname'] . ";");
         } else {
             eval('$content=' . $params['funcname'] . "(\$params);");
         }
         if ($params['type'] == 'array') {
             $ca = json_encode($content);
         } else {
             $ca = $content;
         }
         helper::file_cache($params['cachekey'], $ca);
         return $content;
     } else {
         if ($params['type'] == 'array') {
             $ca = json_decode($cache, 1);
         } else {
             $ca = $cache;
         }
         return $ca;
     }
 }
開發者ID:cranefly,項目名稱:crane,代碼行數:32,代碼來源:common.fun.php


注:本文中的helper::file_cache方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。