提交 91103120 编写于 作者: 李光春's avatar 李光春

- 助手函数增加缓存

上级 48965146
......@@ -14,6 +14,8 @@
// | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
use DtApp\ThinkLibrary\cache\Mysql;
use DtApp\ThinkLibrary\exception\CacheException;
use DtApp\ThinkLibrary\exception\IpException;
use DtApp\ThinkLibrary\service\Ip\QqWryService;
use DtApp\ThinkLibrary\service\SystemService;
......@@ -109,3 +111,28 @@ if (!function_exists('uri')) {
return SystemService::instance()->uri($url, $vars, $suffix, $domain, $fillSuffix);
}
}
if (!function_exists('dtacache')) {
/**
* 缓存
* @param string $name
* @param $value
* @param int $expire
* @return bool|int|string
* @throws CacheException
*/
function dtacache($name = '', $value = [], $expire = 6000)
{
$myc = new Mysql();
if (empty($value)) {
return $myc->name($name)
->get();
} else {
$myc->name($name)
->expire($expire)
->set($value);
return $myc->name($name)
->get();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册