From 820fe85dc9fb6bdc3dd14363bd7663020813c948 Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 23 Apr 2022 12:59:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E8=BF=BD=E5=8A=A0=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/BaseModel.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/common/model/BaseModel.php b/app/common/model/BaseModel.php index c7fea05..279201b 100644 --- a/app/common/model/BaseModel.php +++ b/app/common/model/BaseModel.php @@ -37,15 +37,22 @@ class BaseModel extends Model } public static function autoRemoveCache($model) { - static::$autoCache[] = [ - 'name' => 'table', - 'type' => 'tag' - ]; + + + if(!isset(static::$autoCache['table'])){ + static::$autoCache['table'] = [ + 'name' => 'table', + 'type' => 'tag' + ]; + } + + if(!isset(static::$autoCache['read'])){ + static::$autoCache['read'] = [ + 'name' => 'read', + 'field' => 'id' + ]; + } - static::$autoCache[] = [ - 'name' => 'read', - 'field' => 'id' - ]; foreach (static::$autoCache as $cache_item) { $type = $cache_item['type'] ?? 'key';