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


PHP Q::writeCache方法代码示例

本文整理汇总了PHP中Q::writeCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Q::writeCache方法的具体用法?PHP Q::writeCache怎么用?PHP Q::writeCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q的用法示例。


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

示例1: render

    function render()
    {
        //得到属性的值
        $name = $this->_extract('name');
        $catch_id = 'Dy_menu' . $name;
        //读取缓存
        $rowSet = Q::cache($catch_id);
        //读取失败
        if (!$rowSet) {
            $rowSet = Sysmenu::find()->order('parent_id ASC, order_pos ASC')->asArray()->getAll();
            //写缓存
            Q::writeCache($catch_id, $rowSet);
        }
        /**
         * 验证不能访问的菜单
         */
        $app = MyApp::instance();
        foreach ($rowSet as $offset => $row) {
            if ($row['controller'] == '') {
                continue;
            }
            $udi = "{$row['controller']}/{$row['action']}";
            //权限判断
            if (!$app->authorizedUDI($app->currentUserRoles(), $udi)) {
                //删除没有权限访问的菜单
                unset($rowSet[$offset]);
            } else {
                $args = array();
                parse_str($row['args'], $args);
                $rowSet[$offset]['url'] = url($udi, $args);
            }
        }
        //数组转换成树
        $menu = Helper_Array::toTree($rowSet, 'menu_id', 'parent_id', 'submenu');
        //	 $mainMenu = & new Helper_Menu($menu) ;
        $mainMenu = new Helper_Menu($menu);
        $output = "var {$name} = ";
        $output .= $mainMenu->returnJsArray(true);
        $output .= ";\n";
        echo <<<EOT

<div id="mainMenuBar"></div>

<link href="js/ThemeOffice/theme.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="js/JSCookMenu.js"></script>
<script language="javascript" type="text/javascript" src="js/ThemeOffice/theme.js"></script>

<script language="javascript" type="text/javascript">
{{$output}}

cmDraw ('mainMenuBar', myMenu, 'hbr', cmThemeOffice);
</script>

EOT;
    }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:55,代码来源:menu.php

示例2: testCache

 /**
  * 测试缓存的读写
  *
  * 使用 QCache_Memory
  */
 function testCache()
 {
     $backend = 'QCache_Memory';
     $id = 'test_cache_id1';
     $data = Q::cache($id, null, $backend);
     $this->assertEmpty($data);
     $data = array('value');
     Q::writeCache($id, $data, null, $backend);
     $data2 = Q::cache($id, null, $backend);
     $this->assertEquals($data, $data2);
     Q::cleanCache($id, null, $backend);
     $data2 = Q::cache($id, null, $backend);
     $this->assertEmpty($data2);
 }
开发者ID:Debenson,项目名称:openwan,代码行数:19,代码来源:cache.php

示例3: import

 /**
  * 导入路由规则
  *
  * 如果指定了 $cache_id 参数,则首先尝试从缓存载入解析好的路由规则。
  *
  * @param array $rules
  * @param string $cache_id
  *
  * @return QRouter
  */
 function import(array $rules, $cache_id = null)
 {
     if ($cache_id) {
         $backend = Q::ini('runtime_cache_backend');
         $routes = Q::cache($cache_id, null, $backend);
     }
     if (!$cache_id || !$routes) {
         $routes = array();
         foreach ($rules as $route_name => $rule) {
             $routes[$route_name] = $this->prepareRoute($route_name, $rule);
         }
         if ($cache_id) {
             Q::writeCache($cache_id, $routes, array('life_time' => Q::ini('routes_cache_lifetime')), $backend);
         }
     }
     $this->_routes = array_merge($this->_routes, $routes);
     return $this;
 }
开发者ID:xyz12810,项目名称:xiao3vpn,代码行数:28,代码来源:router.php

示例4: _setupMeta

 /**
  * 设置当前数据表的元数据
  */
 protected function _setupMeta()
 {
     $table_name = $this->getFullTableName();
     $this->_cache_id = $this->_conn->getID() . '-' . $table_name;
     if (isset(self::$_meta[$this->_cache_id])) {
         return;
     }
     $cached = Q::ini('db_meta_cached');
     if ($cached) {
         // 尝试从缓存读取
         $policy = array('encoding_filename' => true, 'serialize' => true, 'life_time' => Q::ini('db_meta_lifetime'), 'cache_dir' => Q::ini('runtime_cache_dir'));
         $backend = Q::ini('db_meta_cache_backend');
         $data = Q::cache($this->_cache_id, $policy, $backend);
         if (is_array($data) && !empty($data)) {
             self::$_meta[$this->_cache_id] = $data[0];
             self::$_fields[$this->_cache_id] = $data[1];
             return;
         }
     }
     // 从数据库获得 meta
     $meta = $this->_conn->metaColumns($table_name);
     $fields = array();
     foreach ($meta as $field) {
         $fields[$field['name']] = true;
     }
     self::$_meta[$this->_cache_id] = $meta;
     self::$_fields[$this->_cache_id] = $fields;
     $data = array($meta, $fields);
     if ($cached) {
         // 缓存数据
         Q::writeCache($this->_cache_id, $data, $policy, $backend);
     }
 }
开发者ID:Debenson,项目名称:openwan,代码行数:36,代码来源:table.php


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