Skip to content

Commit 00d8d2d

Browse files
committed
优化 用户/应用 操作时删除cache
1 parent b621ed0 commit 00d8d2d

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

application/admin/controller/App.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ public function changeStatus() {
148148
} else {
149149
$appInfo = AdminApp::get($id);
150150
cache('AccessToken:' . $appInfo['app_secret'], null);
151+
if($oldWiki = cache('WikiLogin:' . $id)) {
152+
cache('WikiLogin:' . $oldWiki, null);
153+
}
154+
151155
return $this->buildSuccess();
152156
}
153157
}
@@ -180,6 +184,10 @@ public function edit() {
180184
} else {
181185
$appInfo = AdminApp::get($postData['id']);
182186
cache('AccessToken:' . $appInfo['app_secret'], null);
187+
if($oldWiki = cache('WikiLogin:' . $postData['id'])) {
188+
cache('WikiLogin:' . $oldWiki, null);
189+
}
190+
183191
return $this->buildSuccess();
184192
}
185193
}
@@ -198,6 +206,9 @@ public function del() {
198206
cache('AccessToken:' . $appInfo['app_secret'], null);
199207

200208
AdminApp::destroy($id);
209+
if($oldWiki = cache('WikiLogin:' . $id)) {
210+
cache('WikiLogin:' . $oldWiki, null);
211+
}
201212

202213
return $this->buildSuccess();
203214
}

application/admin/controller/User.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ public function changeStatus() {
162162
if ($res === false) {
163163
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
164164
} else {
165+
if($oldAdmin = cache('Login:' . $id)) {
166+
cache('Login:' . $oldAdmin, null);
167+
}
168+
165169
return $this->buildSuccess();
166170
}
167171
}
@@ -201,6 +205,9 @@ public function edit() {
201205
'group_id' => $groups
202206
]);
203207
}
208+
if($oldAdmin = cache('Login:' . $postData['id'])) {
209+
cache('Login:' . $oldAdmin, null);
210+
}
204211

205212
return $this->buildSuccess();
206213
}
@@ -237,6 +244,9 @@ public function own() {
237244
$userData = AdminUserData::get(['uid' => $postData['id']]);
238245
$userData->head_img = $headImg;
239246
$userData->save();
247+
if($oldWiki = cache('WikiLogin:' . $postData['id'])) {
248+
cache('WikiLogin:' . $oldWiki, null);
249+
}
240250

241251
return $this->buildSuccess();
242252
}
@@ -259,6 +269,9 @@ public function del() {
259269
}
260270
AdminUser::destroy($id);
261271
AdminAuthGroupAccess::destroy(['uid' => $id]);
272+
if($oldAdmin = cache('Login:' . $id)) {
273+
cache('Login:' . $oldAdmin, null);
274+
}
262275

263276
return $this->buildSuccess();
264277

0 commit comments

Comments
 (0)