Exemplo n.º 1
0
 /**
  * 默认引擎的初始化
  * Enter description here ...
  */
 protected static function _cache()
 {
     global $gilConfig;
     if (self::$_cache === null) {
         self::$_cache = call_user_func('GilCache' . $gilConfig['cache_config']['cacheEngine'] . '::init', $gilConfig);
         if (!self::$_cache) {
             self::$_cache = new GilCacheUnavailable();
         }
         //服务不可用
     }
     return self::$_cache;
 }
Exemplo n.º 2
0
 public function clean()
 {
     setGPC('sessionid', '', -1);
     GilCache::del(self::$_sessionid);
 }
Exemplo n.º 3
0
 * b表 列bid name
 * 下面,我们来读取数据试试看
 */
//GilDBW::update('test',array('id'=>'4'),array('name'=>'ok'));
GilDBW::insert('test', array('name' => 'hi', 'ext' => '1'));
//插入一条数据
//GilDBW::delete('test',array('id'=>'5'));
GilDBW::save(true);
//执行所有修改,true表示,这是一个事务
$result = gilDB::findSql('select * from test');
//单独地运行SQL语句,读表
//需要特别注意,这里需要自行过滤危险字符串
print_r($result);
GilCache::set('1', 'nihao', '123');
//这里示范了key=>value式的缓存写入,默认使用了File引擎缓存,请在gilFramework下建立一个tmp文件夹用于存放临时文件
echo GilCache::get('1');
GilSession::set('hello', 'hi');
//设置会话信息
echo GilSession::get('hello');
//获得会话信息
GilSession::del('hello');
//删除会话信息
GilSession::clean();
//完全清除本次会话
/**
 * 下面用伪语句的方法读取数据库,这是推荐的方式
 */
//GilDB::cleanCacheByTable('b');//这是比较高级的功能,用于清除MYSQL结果缓存
GilDB::select('test', array('id' => 1), 'id asc', '0,30', 'id,name as aname');
//获取test表,条件是id为1,排序 id asc,分页0,30,获取id和name列,其中name命名为aname,这里除了表名,其它都是可选的
GilDB::link('bdata', 'b', array('aname' => 'name'), 'bid,name');
Exemplo n.º 4
0
 protected static function _setQueryCacheRecord($hash)
 {
     foreach (self::$_selectSpace as $selectSpaceItem) {
         $table = $selectSpaceItem['table'];
         $index = GilCache::get('DBCACHE_' . $table);
         $index[$hash] = self::$_gilConfig['db_resultCache_config']['expired'] + time();
         if (mt_rand(0, 10) == 1) {
             foreach ($index as $k => $v) {
                 if ($v < time()) {
                     unset($index[$k]);
                 }
                 //垃圾收集机制
             }
         }
         GilCache::set('DBCACHE_' . $table, $index, self::$_gilConfig['db_resultCache_config']['expired']);
     }
 }