# 緩存開發規范
緩存主要是針對寫不頻繁的數據進行處理。進行表設計需要考慮靜態數據(寫不頻繁的數據)和動態數據
1. model層設置緩存,比如文章,列表等增加緩存
```
<pre class="calibre15">```
/**
* 列表
* @param array $where
* @param int $limit
* @param string $order
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where,int $limit = 0, string $order = ''){
return $this->where($where)->cache()->field('id,app_type,menu_name,menu_key,parent_key,icon,api_url,methods,params,sort,is_show,is_show_path,access,menu_path,path,auth_type,header,is_header,unique_auth,is_del')->limit($limit)->order($order)->select()->toArray();
}
```
```
2. 單獨設置緩存(參考thinkphp手冊)