function display($template, $cache = 0, $args = null) { $displayHtml = parent::fetch($template); if (is_null($args) || (int) $args > count(Q('args'))) { if (intval($cache) > 0) { \SysFactory::memcache()->set(Q('cacheKey'), $displayHtml, $cache); } else { if (Q('cacheTime') > 0) { \SysFactory::memcache()->set(Q('cacheKey'), $displayHtml, Q('cacheTime')); } } } if (preg_match_all('/{{{(.*?)}}}/', $displayHtml, $cacheProMatch)) { $SysCachePro = new cachePro($cacheProMatch); $displayHtml = strtr($displayHtml, $SysCachePro->getConfig()); unset($SysCachePro); } echo $displayHtml; }
static function getTableInfo($dbName, $tableName) { //生成缓存Key [tableSys#库名#表名] $memKey = 'tableSys#' . $dbName . '#' . $tableName; //DEBUG模式下不记录缓存 $info = DEBUG ? false : \SysFactory::memcache()->get($memKey); if ($info === false) { $res = self::getConnect($dbName)->query('DESC ' . $tableName); $res or errorMsg('<b>' . $tableName . '</b> 这个表在数据库中不存在!', E_USER_ERROR); $info = array(); $info['list'] = array(); foreach ($res->fetchAll(\PDO::FETCH_ASSOC) as $item) { //记录字段列表 array_push($info['list'], $item['Field']); //记录主键 if ($item['Key'] == 'PRI') { $info['pri'] = $item['Field']; } } //如里没有主键则第一具字段填充 empty($info['pri']) and $table['pri'] = reset($table['list']); //加入缓存 \SysFactory::memcache()->set($memKey, $info, 3600); } return $info; }