request->isAjax()) { $data = $this->postData('cache'); $this->rmCache($data['keys'], isset($data['isForce']) ? !!$data['isForce'] : false); return $this->renderSuccess('操作成功'); } return View::fetch('clear', [ 'cacheList' => $this->getCacheKeys(), 'isForce' => !!$isForce ?: config('app_debug'), ]); } /** * 删除缓存 */ private function rmCache($keys, $isForce = false) { if ($isForce === true) { Driver::clear(); } else { $cacheList = $this->getCacheKeys(); foreach (array_intersect(array_keys($cacheList), $keys) as $key) { Driver::has($cacheList[$key]['key']) && Driver::delete($cacheList[$key]['key']); } } } /** * 获取缓存索引数据 */ private function getCacheKeys() { return [ 'setting' => [ 'key' => 'setting_0', 'name' => '站点设置' ], 'link' => [ 'key' => 'hema_link', 'name' => '友情链接' ], ]; } }