Inheritance: extends Cache_MemCache
Esempio n. 1
0
 function pageEntry($inPath)
 {
     /**
      * 获取Cache Engine,SCache共支持三种缓存,分别是 File, APC, MemCache
      */
     /**
      * 文件cache例子 File Cache Samples
      */
     $cache = SCache::getCacheEngine($cacheengine = "File");
     if (!$cache) {
         die("File cache engine not exists");
     }
     /**
      * 初始参数,这里的dir为必要参数,depth表示目录深度
      */
     $cache->init(array("dir" => SlightPHP::$appDir . "../cache", "depth" => 3));
     /**
      * 设置
      */
     var_dump($cache->set("name", new stdclass()));
     /**
      * 获取
      */
     var_dump($cache->get("name2"));
     var_dump($cache->get("name"));
     /**
      * 删除
      */
     var_dump($cache->del("name"));
     /**
      * APC Cache Samples
      */
     $cache = SCache::getCacheEngine($cacheengine = "APC");
     if (!$cache) {
         die("APC cache engine not exists");
     }
     var_dump($cache->set("name", new stdclass()));
     var_dump($cache->get("name2"));
     var_dump($cache->get("name"));
     var_dump($cache->del("name"));
     /**
      * Memcache Cache Samples
      */
     /**
      * 初始化参数,其实host为必要参数 
      */
     SCache::useConfig("video");
     var_dump(SCache::set("name", new stdclass()));
     var_dump(SCache::get("name2"));
     var_dump(SCache::get("name"));
     var_dump(SCache::del("name"));
 }
Esempio n. 2
0
 public function getOne($mgid)
 {
     $cacheName = "member_group_" . $mgid;
     $cache = SCache::getCacheEngine('file');
     $cache->init(array("dir" => SlightPHP::$appDir . "/cache", "depth" => 3));
     $rs = unserialize($cache->get($cacheName));
     if (!$rs) {
         $this->setPkid($mgid);
         $rs = $this->get();
         $cache->set($cacheName, serialize($rs));
     }
     return $rs;
 }
Esempio n. 3
0
 private function getRights()
 {
     $gid = (int) $_COOKIE['gid'];
     $cacheName = "action_code_group_" . $gid;
     $cache = SCache::getCacheEngine('file');
     $cache->init(array("dir" => SlightPHP::$appDir . "/cache", "depth" => 3));
     $rs = $cache->get($cacheName);
     if ($cache and $rs) {
     } else {
         $rsObj = base_mAPI::get('m_group', $gid);
         $rs = $rsObj->get();
         $cache->set($cacheName, $rs);
     }
     $action = unserialize($rs['action_code']);
     $this->params['head_title'] = base_Constant::DEFAULT_TITLE;
     $this->params['menu'] = $action['menu'];
     $this->params['_userid'] = $_COOKIE['admin_id'];
     $this->params['_adminname'] = $_COOKIE['admin_name'];
 }
Esempio n. 4
0
 function pagerights($inPath)
 {
     $url = $this->getUrlParams($inPath);
     $groupObj = new m_group();
     $gid = (int) $url['gid'];
     $this->params['gid'] = $gid;
     if (!$gid) {
         $this->params['group'] = $groupObj->select()->items;
         return $this->render('system/rights.html', $this->params);
     } else {
         if (!$_POST) {
             if ($gid) {
                 $this->params['rights'] = $groupObj->selectOne("gid = {$gid}");
                 $this->params['action'] = unserialize($this->params['rights']['action_code']);
                 return $this->render('system/rightsshow.html', $this->params);
             }
             $this->ShowMsg("用户组不存在!");
         } else {
             $action_code = $this->creatRights($_POST);
             $groupObj->update("gid = {$gid}", "action_code = '{$action_code}'");
             $cacheName = "action_code_group_" . $gid;
             $cache = SCache::getCacheEngine('file');
             $cache->init(array("dir" => SlightPHP::$appDir . "/cache", "depth" => 3));
             $rs = $cache->del($cacheName);
             $this->ShowMsg("编辑成功!", $this->createUrl('/system/rights'), '', 1);
         }
     }
 }
Esempio n. 5
0
 static function setConfigFile($file)
 {
     self::$_config = new SConfig();
     self::$_config->setConfigFile($file);
 }
Esempio n. 6
0
 static function setConfigFile($file)
 {
     self::$_config = $file;
 }