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


PHP cache_factory::get_instance方法代碼示例

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


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

示例1: getcacheinfo

/**
 * 讀取緩存,默認為文件緩存,不加載緩存配置。
 * @param string $name 緩存名稱
 * @param $filepath 數據路徑(模塊名稱) caches/cache_$filepath/
 * @param string $config 配置名稱
 */
function getcacheinfo($name, $filepath = '', $type = 'file', $config = '')
{
    if (!preg_match("/^[a-zA-Z0-9_-]+\$/", $name)) {
        return false;
    }
    if ($filepath != "" && !preg_match("/^[a-zA-Z0-9_-]+\$/", $filepath)) {
        return false;
    }
    pc_base::load_sys_class('cache_factory');
    if ($config) {
        $cacheconfig = pc_base::load_config('cache');
        $cache = cache_factory::get_instance($cacheconfig)->get_cache($config);
    } else {
        $cache = cache_factory::get_instance()->get_cache($type);
    }
    return $cache->cacheinfo($name, '', '', $filepath);
}
開發者ID:zhangjSir,項目名稱:JinMaSite,代碼行數:23,代碼來源:global.func.php

示例2: getcacheinfo

/**
 * 讀取緩存,默認為文件緩存,不加載緩存配置。
 * @param string $name 緩存名稱
 * @param $filepath 數據路徑(模塊名稱) caches/cache_$filepath/
 * @param string $config 配置名稱
 */
function getcacheinfo($name, $filepath = '', $type = 'file', $config = '')
{
    pc_base::load_sys_class('cache_factory');
    if ($config) {
        $cacheconfig = pc_base::load_config('cache');
        $cache = cache_factory::get_instance($cacheconfig)->get_cache($config);
    } else {
        $cache = cache_factory::get_instance()->get_cache($type);
    }
    return $cache->cacheinfo($name, '', '', $filepath);
}
開發者ID:hw18708118867,項目名稱:htmlmoban,代碼行數:17,代碼來源:global.func.php

示例3: get_content

 function get_content()
 {
     if ($this->settings['cache_expire_time']) {
         /**先從緩存讀取數據 緩存不存在或過期時再從表中查詢*/
         include_once ROOT_PATH . 'lib/class/cache/cache.class.php';
         $cache_factory = cache_factory::get_instance();
         $cache_type = $this->settings['cache_type'] ? $this->settings['cache_type'] : 'file';
         $cache_driver = $cache_factory->get_cache_driver($cache_type);
         $input = $this->input;
         unset($input['access_token'], $input['lpip']);
         $cache_id = md5(serialize($input));
         $data = $cache_driver->get($cache_id);
         if ($data) {
             $this->addItem($data);
             $this->output();
         }
         /**先從緩存讀取數據 緩存不存在或過期時再從表中查詢*/
     }
     //$condition = $this->get_condition();
     $offset = $this->input['page'] ? $this->input['page_num'] * ($this->input['page'] - 1) : 0;
     $count = $this->input['page_num'] ? intval($this->input['page_num']) : 20;
     $con = $con_count = $this->con_process();
     $con['offset'] = $offset;
     $con['count'] = $count;
     $content = $this->obj->get_content($con);
     include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
     $this->publishcontent = new publishcontent();
     $content_type = $this->publishcontent->get_all_content_type();
     $pub_content_bundle = array();
     foreach ((array) $content_type as $k => $v) {
         $pub_content_bundle[] = $v['bundle_id'];
     }
     include_once ROOT_PATH . 'lib/class/auth.class.php';
     $this->auth = new Auth();
     $app_info = $this->auth->get_app();
     $module = array();
     foreach ((array) $app_info as $k => $v) {
         if (!empty($v)) {
             $module[$v['bundle']] = $v['name'];
         }
     }
     $cidArr = array();
     $conArr = array();
     $other_content = array();
     foreach ((array) $content as $row) {
         if (!in_array($row['app_bundle'], $pub_content_bundle)) {
             $row['bundle_name'] = $module[$row['app_bundle']];
             if (!$row['bundle_name']) {
                 $row['bundle_name'] = $this->settings["App_{$row['app_bundle']}"]['name'];
             }
             if (!$row['bundle_name']) {
                 $row['bundle_name'] = $row['app_bundle'];
             }
             $row['content_url'] = $row['url'];
             $row['access_nums'] = $row['num'];
             $other_content[] = $row;
         } else {
             $cidArr[] = $row['cid'];
             $conArr[$row['cid']] = array('access_nums' => $row['num']);
         }
     }
     $cidStr = implode(',', $cidArr);
     $ret = $this->publishcontent->get_content_by_cid($cidStr);
     if (!is_array($ret)) {
         //return array();
     }
     $ret = (array) $ret;
     $arExistIds = array();
     foreach ($ret as $k => $v) {
         $arExistIds[] = $v['cid'];
         $ret[$k]['bundle_name'] = $module[$v['bundle_id']];
         if (!$ret[$k]['bundle_name']) {
             $ret[$k]['bundle_name'] = $this->settings["App_{$v['bundle_id']}"]['name'];
         }
         if (!$ret[$k]['bundle_name']) {
             $ret[$k]['bundle_name'] = $v['bundle_id'];
         }
         $ret[$k] = array_merge($ret[$k], $conArr[$k]);
     }
     $ret = array_merge($ret, $other_content);
     //發布庫刪除沒有更新統計時條數不準確 下麵代碼為解決此bug
     //對比cid差集
     $delCid = array_diff($cidArr, $arExistIds);
     //更新已經不存在的內容
     if (!empty($delCid)) {
         $cid = implode(',', $delCid);
         $sql = "UPDATE " . DB_PREFIX . "nums SET del = 1 WHERE cid IN(" . $cid . ")";
         $this->db->query($sql);
         include_once CUR_CONF_PATH . 'lib/cache.class.php';
         $cache = new CacheFile();
         $table = $cache->get_cache('access_table_name');
         $table = convert_table_name($table);
         if ($table) {
             $table_str = implode(',', $table);
         }
         $sql = "ALTER TABLE " . DB_PREFIX . "merge UNION(" . $table_str . ")";
         $this->db->query($sql);
         $sql = "UPDATE " . DB_PREFIX . "merge SET del = 1 WHERE cid IN(" . $cid . ")";
         $this->db->query($sql);
     }
//.........這裏部分代碼省略.........
開發者ID:h3len,項目名稱:Project,代碼行數:101,代碼來源:access.php


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