public function get($key, $and = true, $useMaster = false, $tablePrefix = null)
{
if (is_string($useMaster) && is_null($tablePrefix)) {
$tablePrefix = $useMaster;
$useMaster = false;
}
is_null($tablePrefix) && ($tablePrefix = $this->tablePrefix);
list($tableName, $condition) = $this->parseKey($key, $and);
$tableName = $tablePrefix . $tableName;
$sql = "SELECT * FROM {$tableName} WHERE {$condition} LIMIT 0, 1000";
$cacheKey = md5($sql . json_encode($this->bindParams)) . $this->getCacheVer($tableName);
$return = Model::getInstance()->cache()->get($cacheKey);
if ($return === false) {
//cache中不存在这条记录
$stmt = $this->prepare($sql, $useMaster ? $this->wlink : $this->rlink);
$this->execute($stmt);
$return = $stmt->fetchAll(\PDO::FETCH_ASSOC);
Model::getInstance()->cache()->set($cacheKey, $return, $this->conf['cache_expire']);
} else {
if (Cml::$debug) {
$this->currentSql = $sql;
$this->debugLogSql(Debug::SQL_TYPE_FROM_CACHE);
$this->currentSql = '';
}
$this->clearBindParams();
}
return $return;
}