更新内核,API接口开发的一些尝试,后期会增加API接口开发这块

This commit is contained in:
2017-05-22 20:48:10 +08:00
parent a4d58f9f09
commit 426195eb90
47 changed files with 1339 additions and 513 deletions

View File

@@ -192,7 +192,7 @@ if (!function_exists('db')) {
* @param bool $force 是否强制重新连接
* @return \think\db\Query
*/
function db($name = '', $config = [], $force = true)
function db($name = '', $config = [], $force = false)
{
return Db::connect($config, $force)->name($name);
}
@@ -354,22 +354,25 @@ if (!function_exists('cache')) {
{
if (is_array($options)) {
// 缓存操作的同时初始化
Cache::connect($options);
$cache = Cache::connect($options);
} elseif (is_array($name)) {
// 缓存初始化
return Cache::connect($name);
} else {
$cache = Cache::init();
}
if (is_null($name)) {
return Cache::clear($value);
return $cache->clear($value);
} elseif ('' === $value) {
// 获取缓存
return 0 === strpos($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name);
return 0 === strpos($name, '?') ? $cache->has(substr($name, 1)) : $cache->get($name);
} elseif (is_null($value)) {
// 删除缓存
return Cache::rm($name);
return $cache->rm($name);
} elseif (0 === strpos($name, '?') && '' !== $value) {
$expire = is_numeric($options) ? $options : null;
return Cache::remember(substr($name, 1), $value, $expire);
return $cache->remember(substr($name, 1), $value, $expire);
} else {
// 缓存数据
if (is_array($options)) {
@@ -378,9 +381,9 @@ if (!function_exists('cache')) {
$expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间
}
if (is_null($tag)) {
return Cache::set($name, $value, $expire);
return $cache->set($name, $value, $expire);
} else {
return Cache::tag($tag)->set($name, $value, $expire);
return $cache->tag($tag)->set($name, $value, $expire);
}
}
}