mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
Query类的update和delete方法支持调用cache方法 会自动清除指定key的缓存 配合查询方法的cache方法一起使用 Model类的get方法第三个参数传入true的时候会自动更新缓存
This commit is contained in:
@@ -985,9 +985,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
*/
|
||||
public static function get($data = null, $with = [], $cache = false)
|
||||
{
|
||||
if (!$cache && $data && is_scalar($data)) {
|
||||
$cache = true;
|
||||
}
|
||||
$query = static::parseQuery($data, $with, $cache);
|
||||
return $query->find($data);
|
||||
}
|
||||
|
||||
@@ -1769,6 +1769,10 @@ class Query
|
||||
{
|
||||
$options = $this->parseExpress();
|
||||
$pk = $this->getPk($options);
|
||||
if (isset($options['cache']) && is_string($options['cache'])) {
|
||||
$key = $options['cache'];
|
||||
}
|
||||
|
||||
if (empty($options['where'])) {
|
||||
// 如果存在主键数据 则自动作为更新条件
|
||||
if (is_string($pk) && isset($data[$pk])) {
|
||||
@@ -2095,6 +2099,9 @@ class Query
|
||||
{
|
||||
// 分析查询表达式
|
||||
$options = $this->parseExpress();
|
||||
if (isset($options['cache']) && is_string($options['cache'])) {
|
||||
$key = $options['cache'];
|
||||
}
|
||||
|
||||
if (!is_null($data) && true !== $data) {
|
||||
if (!is_array($data)) {
|
||||
|
||||
Reference in New Issue
Block a user