当前位置: 首页>>代码示例>>PHP>>正文


PHP cache函数代码示例

本文整理汇总了PHP中cache函数的典型用法代码示例。如果您正苦于以下问题:PHP cache函数的具体用法?PHP cache怎么用?PHP cache使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     if (($data = cache()->get(CacheNames::SERVER_STATUS)) === FALSE) {
         if (config('server_status.allow') == 1) {
             $data['content'] = array();
             $data['totalOnline'] = 0;
             $criteria = new CDbCriteria(array('select' => 't.name, t.id, t.fake_online, t.ip, t.port', 'scopes' => array('opened'), 'with' => array('ls' => array('select' => 'ls.ip, ls.port, ls.name', 'scopes' => array('opened')))));
             $gsList = Gs::model()->findAll($criteria);
             if ($gsList) {
                 foreach ($gsList as $gs) {
                     try {
                         $l2 = l2('gs', $gs->id)->connect();
                         // Кол-во игроков
                         $online = $l2->getDb()->createCommand("SELECT COUNT(0) FROM `characters` WHERE `online` = 1")->queryScalar();
                         // Fake online
                         if (is_numeric($gs->fake_online) && $gs->fake_online > 0) {
                             $online += Lineage::fakeOnline($online, $gs->fake_online);
                         }
                         $data['content'][$gs->id] = array('gs_status' => Lineage::getServerStatus($gs->ip, $gs->port), 'ls_status' => isset($gs->ls) ? Lineage::getServerStatus($gs->ls->ip, $gs->ls->port) : 'offline', 'online' => $online, 'gs' => $gs);
                         $data['totalOnline'] += $online;
                     } catch (Exception $e) {
                         $data[$gs->id]['error'] = $e->getMessage();
                     }
                 }
             }
             if (config('server_status.cache') > 0) {
                 cache()->set(CacheNames::SERVER_STATUS, $data, config('server_status.cache') * 60);
             }
         }
     }
     app()->controller->renderPartial('//server-status', $data);
 }
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:32,代码来源:ServerStatus.php

示例2: yql

function yql($q, $fmt = 'xml')
{
    $yql = "http://query.yahooapis.com/v1/public/yql?q=";
    $env = 'store://datatables.org/alltableswithkeys';
    $x = simplexml_load_file(cache($yql . urlencode($q) . "&format={$fmt}&env=" . urlencode($env)));
    return $x;
}
开发者ID:SandyS1,项目名称:presentations,代码行数:7,代码来源:yql.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $page = cache('pages')->filter(function ($page) {
         return $page->url == "events";
     })->first();
     // Delete all record first
     DB::table('layout_events')->truncate();
     $photoType = ['abstract', "animal", "business", "cats", "city", "food", "nightlife", "fashion", "people", "nature", "sports", "technics", "transport"];
     $months = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
     $catList = ['Dance', "Drama", "Sport", "Party"];
     foreach ($months as $month) {
         for ($day = 1; $day <= (int) date('t', strtotime("2015-{$month}")); $day++) {
             $number = rand(0, 5);
             if ($day < 10) {
                 $date = "0{$day}";
             } else {
                 $date = $day;
             }
             if ($number > 0) {
                 for ($i = 0; $i < $number; $i++) {
                     $type = $photoType[rand(0, 12)];
                     $cat = $catList[rand(0, 3)];
                     $startDate = Carbon::create(2015, $month, $date);
                     $endDate = Carbon::create(2015, $month, $date)->addDays(rand(1, 5));
                     $data = ['lang_id' => 1, 'meta_title' => "Event {$i} on day {$day}", 'meta_description' => "Lorem ipsum dolor sit amet, ea elit dolore urbanitas quo. Est assum cetero ei. Eam semper docendi id. Mucius doming.", 'page_id' => $page->id, 'content_identifier' => "event_seeder_{$month}-{$day}-{$i}", 'active' => 1, 'eventStartDate' => $startDate->format("Y-m-d h:i:s"), 'eventEndDate' => $endDate->format("Y-m-d h:i:s"), 'address' => "hong Kong", 'image1' => "http://lorempixel.com/380/300/{$type}", 'image2' => "http://lorempixel.com/380/300/{$type}", 'image3' => "http://lorempixel.com/380/300/{$type}", 'image4' => "http://lorempixel.com/380/300/{$type}", 'summary' => "this is the summary for a {$cat} event {$i} on {$date} {$month}", 'detail' => "Lorem ipsum dolor sit amet, consectetur adipisicing elit. A ad aliquam aperiam, consectetur debitis delectus dicta distinctio dolorum ea enim non odio placeat, quam quibusdam unde vero, voluptas voluptatibus? Accusantium alias amet, autem consectetur delectus dicta dignissimos esse id incidunt inventore ipsam maxime, provident quaerat quisquam quod sunt suscipit veritatis voluptas? A animi aperiam architecto dignissimos ducimus exercitationem, explicabo facilis id iste itaque labore maxime modi provident, quos, ratione recusandae repellendus sunt tenetur ut vero? Adipisci alias aliquam aliquid aperiam cumque delectus dignissimos dolorem doloribus et facere harum itaque mollitia nobis provident quia, repudiandae sint sit soluta temporibus vitae voluptatibus.", 'cat' => $cat];
                     DB::table('layout_events')->insert($data);
                 }
             }
         }
     }
 }
开发者ID:xavierauana,项目名称:events,代码行数:36,代码来源:EventTableSeeder.php

示例4: init

 public function init()
 {
     $data = array('content' => array(), 'error' => Yii::t('main', 'Модуль отключен.'));
     if (config('forum_threads.allow') == 1) {
         $data = cache()->get(CacheNames::FORUM_THREADS);
         if ($data === FALSE) {
             $data = array();
             try {
                 // Подключаюсь к БД
                 $this->db = Yii::createComponent(array('class' => 'CDbConnection', 'connectionString' => 'mysql:host=' . config('forum_threads.db_host') . ';port=' . config('forum_threads.db_port') . ';dbname=' . config('forum_threads.db_name'), 'enableProfiling' => YII_DEBUG, 'enableParamLogging' => TRUE, 'username' => config('forum_threads.db_user'), 'password' => config('forum_threads.db_pass'), 'charset' => 'utf8', 'emulatePrepare' => TRUE, 'tablePrefix' => config('forum_threads.prefix')));
                 app()->setComponent('ForumThreadsDb', $this->db);
                 $forumType = config('forum_threads.type');
                 if (method_exists($this, $forumType)) {
                     $data['content'] = $this->{$forumType}();
                     foreach ($data['content'] as $k => $v) {
                         $data['content'][$k]['user_link'] = $this->getUserLink($v['starter_id'], $v['starter_name']);
                         $data['content'][$k]['theme_link'] = $this->getForumLink($v['id_topic'], $v['title'], $v['id_forum']);
                         $data['content'][$k]['start_date'] = $this->getStartDate($v['start_date']);
                     }
                     if (config('forum_threads.cache')) {
                         cache()->set(CacheNames::FORUM_THREADS, $data, config('forum_threads.cache') * 60);
                     }
                 } else {
                     $data['error'] = Yii::t('main', 'Метод для обработки форума: :type не найден.', array(':type' => '<b>' . $forumType . '</b>'));
                 }
             } catch (Exception $e) {
                 $data['error'] = $e->getMessage();
             }
         }
     }
     app()->controller->renderPartial('//forum-threads', $data);
 }
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:32,代码来源:ForumThreads.php

示例5: actionIndex

 /**
  * 用户组绑定权限
  */
 public function actionIndex($id)
 {
     $id = (int) $id;
     $model = Group::model()->findByPk($id);
     if ($model->access) {
         foreach ($model->access as $g) {
             $access[] = $g->access_id;
         }
     }
     $cache = cache('auth_controller_file');
     if (!$cache) {
         $d = $this->_get_modules(\Yii::getPathOfAlias('application.modules'));
         if ($d) {
             Access::generate($d);
         }
         DirHelper::$kep_list_file = false;
         cache('auth_controller_file', true);
     }
     $rows = DB::all('access', array('select' => "id,name,pid"));
     foreach ($rows as $v) {
         $out[$v['id']] = $v;
     }
     $rows = ArrHelper::_tree_id($rows);
     if ($_POST) {
         $auth = $_POST['auth'];
         GroupAccess::saveAccess($id, $auth);
         cache('acl', false);
         flash('success', __('set access success'));
         $this->redirect(url('admin/auth/index', array('id' => $id)));
     }
     return $this->render('index', array('rows' => $rows, 'out' => $out, 'model' => $model, 'id' => $id, 'access' => $access));
 }
开发者ID:hiproz,项目名称:mincms,代码行数:35,代码来源:AuthController.php

示例6: actionUpdate

 public function actionUpdate()
 {
     if ($_POST) {
         cache('defaultDBLanguge', false);
     }
     $this->render('update');
 }
开发者ID:hiproz,项目名称:mincms,代码行数:7,代码来源:LanguageController.php

示例7: actionIndex

 public function actionIndex()
 {
     $rows = CDB()->from('configs')->queryAll();
     if ($rows) {
         foreach ($rows as $v) {
             $data[$v['name']] = $v['body'];
         }
     }
     if ($_POST['config']) {
         $config = $_POST['config'];
         if ($config) {
             CDB()->update('configs', array('body' => ""));
             foreach ($config as $k => $v) {
                 $row = CDB()->from('configs')->where("name=:name", array(':name' => $k))->queryRow();
                 if (!$row) {
                     CDB()->insert('configs', array('name' => $k, 'body' => $v));
                 } else {
                     CDB()->update('configs', array('body' => $v), "name=:name", array(':name' => $k));
                 }
             }
             flash('success', __('success'));
             cache('config', false);
             $this->refresh();
         }
     }
     $this->render('index', $data);
 }
开发者ID:hiproz,项目名称:mincms,代码行数:27,代码来源:DefaultController.php

示例8: cacheGet

function cacheGet($k)
{
    global $cacheHost;
    $v = cache($cacheHost, array('act' => 'get', 'key' => $k));
    //echo "(cacheGet($k) returning ".($v === null ? "null" : $v).")\n";
    return $v;
}
开发者ID:piter65,项目名称:spilldec,代码行数:7,代码来源:cache.php

示例9: add

 public function add($data)
 {
     $ContentModel = ContentModel::getInstance($this->_mid);
     if (!isset($this->_model[$this->_mid])) {
         $this->error = '模型不存在';
     }
     $ContentInputModel = new ContentInputModel($this->_mid);
     $insertData = $ContentInputModel->get($data);
     if ($insertData == false) {
         $this->error = $ContentInputModel->error;
         return false;
     }
     if ($ContentModel->create($insertData)) {
         $result = $ContentModel->add($insertData);
         $aid = $result[$ContentModel->table];
         $this->editTagData($aid);
         M('upload')->where(array('uid' => $_SESSION['uid']))->save(array('state' => 1));
         //============记录动态
         $DMessage = "发表了文章:<a target='_blank' href='" . U('Index/Index/content', array('mid' => $insertData['mid'], 'cid' => $insertData['cid'], 'aid' => $aid)) . "'>{$insertData['title']}</a>";
         addDynamic($_SESSION['uid'], $DMessage);
         //内容静态
         $Html = new Html();
         $Html->content($this->find($aid));
         $categoryCache = cache('category');
         $cat = $categoryCache[$insertData['cid']];
         $Html->relation_category($insertData['cid']);
         $Html->index();
         return $aid;
     } else {
         $this->error = $ContentModel->error;
         return false;
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:33,代码来源:Content.class.php

示例10: del

 public function del()
 {
     if (IS_POST) {
         $uid = Q('uid', 0, 'intval');
         //删除文章
         if (Q('post.delcontent')) {
             $ModelCache = cache('model');
             foreach ($ModelCache as $model) {
                 $contentModel = ContentModel::getInstance($model['mid']);
                 $contentModel->where(array('uid' => $uid))->del();
             }
         }
         //删除评论
         if (Q('post.delcomment')) {
             M('comment')->where(array('uid' => $uid))->del();
         }
         //删除附件
         if (Q('post.delupload')) {
             M('upload')->where(array('uid' => $uid))->del();
         }
         //删除用户
         M('user')->del($uid);
         $this->success('删除成功...');
     } else {
         $uid = Q("uid", 0, "intval");
         $field = M('user')->find($uid);
         $this->assign('field', $field);
         $this->display();
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:30,代码来源:UserControl.class.php

示例11: cmd

 private static function cmd($cmd, $name, $ttl = 0)
 {
     if ('file' == getini('cache/cacher')) {
         return self::dblock($cmd, $name, $ttl);
     }
     return cache($cmd, 'process_' . $name, time(), $ttl);
 }
开发者ID:locphp,项目名称:rsf,代码行数:7,代码来源:Locker.php

示例12: render

 function render($name, $params = array(), $loadHelpers = false)
 {
     $view =& ClassRegistry::getObject('view');
     $file = $plugin = $key = null;
     if (isset($params['cache'])) {
         $expires = '+1 day';
         if (is_array($params['cache'])) {
             $expires = $params['cache']['time'];
             $key = Inflector::slug($params['cache']['key']);
         } elseif ($params['cache'] !== true) {
             $expires = $params['cache'];
             $key = implode('_', array_keys($params));
         }
         if ($expires) {
             $cacheFile = 'partial_' . $key . '_' . Inflector::slug($name);
             $cache = cache('views' . DS . $cacheFile, null, $expires);
             if (is_string($cache)) {
                 return $cache;
             }
         }
     }
     $buf = explode(DS, $name);
     $buf[count($buf) - 1] = '_' . $buf[count($buf) - 1];
     $name = implode(DS, $buf);
     if ($partial = $view->render($name, false)) {
         if (isset($params['cache']) && isset($cacheFile) && isset($expires)) {
             cache('views' . DS . $cacheFile, $partial, $expires);
         }
         return $partial;
     }
     if (Configure::read() > 0) {
         return "Not Found: " . str_replace(DS . DS, DS, $view->viewPath . DS . $name);
     }
 }
开发者ID:hiromi2424,项目名称:PartialHelper,代码行数:34,代码来源:partial.php

示例13: contentReplace

 public function contentReplace()
 {
     if (IS_POST) {
         $WHERE = !empty($_POST['replacewhere']) ? " WHERE {$_POST['replacewhere']}" : '';
         $VALUE = "replace({$_POST['field']},'{$_POST['searchcontent']}','{$_POST['replacecontent']}')";
         $sql = "UPDATE " . $_POST['table'] . " SET {$_POST['field']}={$VALUE} {$WHERE}";
         if (M()->exe($sql)) {
             $this->success('替换成功!');
         } else {
             $this->error('替换失败...');
         }
     } else {
         $tableCache = cache('table');
         if (!$tableCache) {
             $Model = M();
             $tableInfo = $Model->getTableInfo();
             $tables = $tableInfo['table'];
             cache('table', $tables);
             $tableCache = $tables;
         }
         $this->assign("tablesJson", json_encode($tableCache));
         $this->assign('tables', $tableCache);
         $this->display();
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:25,代码来源:TableControl.class.php

示例14: posid

/**
 * 推荐字段类型表单组合处理
 * @param type $field 字段名
 * @param type $value 字段内容
 * @param type $fieldinfo 字段配置
 * @return string
 */
function posid($field, $value, $fieldinfo)
{
    //扩展配置
    $setting = unserialize($fieldinfo['setting']);
    //推荐位缓存
    $position = cache('Position');
    if (empty($position)) {
        return '';
    }
    $array = array();
    foreach ($position as $_key => $_value) {
        //如果有设置模型,检查是否有该模型
        if ($_value['modelid'] && !in_array($this->modelid, explode(',', $_value['modelid']))) {
            continue;
        }
        //如果设置了模型,又设置了栏目
        if ($_value['modelid'] && $_value['catid'] && !in_array($this->catid, explode(',', $_value['catid']))) {
            continue;
        }
        //如果设置了栏目
        if ($_value['catid'] && !in_array($this->catid, explode(',', $_value['catid']))) {
            continue;
        }
        $array[$_key] = $_value['name'];
    }
    $posids = array();
    if (ACTION_NAME == 'edit') {
        $result = M('PositionData')->where(array('id' => $this->id, 'modelid' => $this->modelid))->getField("posid,id,catid,posid,module,modelid,thumb,data,listorder,expiration,extention,synedit");
        $posids = implode(',', array_keys($result));
    } else {
        $posids = $setting['defaultvalue'];
    }
    return "<input type='hidden' name='info[{$field}][]' value='-1'>" . \Form::checkbox($array, $posids, "name='info[{$field}][]'", '', $setting['width']);
}
开发者ID:sandom123,项目名称:king400,代码行数:41,代码来源:form.inc.php

示例15: __construct

 /**
  * 架构函数
  * @param array $options 配置参数
  * @access public
  */
 function __construct($options = array())
 {
     //网站配置
     $this->config = cache("Config");
     $options = array_merge(array('userid' => 0, 'groupid' => 8, 'isadmin' => 0, 'catid' => 0, 'module' => 'content ', 'watermarkenable' => $this->config['watermarkenable'], 'thumb' => false, 'time' => time(), 'dateFormat' => 'Y/m'), $options);
     $this->options = $options;
     //附件访问地址
     $this->options['sitefileurl'] = $this->config['sitefileurl'];
     //附件存放路径
     $this->options['uploadfilepath'] = C('UPLOADFILEPATH');
     //允许上传的附件大小
     if (empty($this->options['uploadmaxsize'])) {
         $this->options['uploadmaxsize'] = $this->options['isadmin'] ? (int) $this->config['uploadmaxsize'] * 1024 : (int) $this->config['qtuploadmaxsize'] * 1024;
     }
     //允许上传的附件类型
     if (empty($this->options['uploadallowext'])) {
         $this->options['uploadallowext'] = $this->options['isadmin'] ? explode("|", $this->config['uploadallowext']) : explode("|", $this->config['qtuploadallowext']);
     }
     //上传目录
     $this->options['savePath'] = D('Attachment/Attachment')->getFilePath($this->options['module'], $this->options['dateFormat'], $this->options['time']);
     //如果生成缩略图是否移除原图
     $this->options['thumbRemoveOrigin'] = false;
     $this->handler = new \UploadFile();
     //设置上传类型
     $this->handler->allowExts = $this->options['uploadallowext'];
     //设置上传大小
     $this->handler->maxSize = $this->options['uploadmaxsize'];
     //设置本次上传目录,不存在时生成
     $this->handler->savePath = $this->options['savePath'];
 }
开发者ID:sandom123,项目名称:king400,代码行数:35,代码来源:Local.class.php


注:本文中的cache函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。