public function del($key) { unset(self::$_sessionData[$key]); GilCache::set(self::$_sessionid, self::$_sessionData); }
* 我们在数据库中有2个表 * test表 列 id name * 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');
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']); } }