## Cache
~~~php
// 獲取緩存對象,約等于 Cache
cache()
// 注意 5.8 緩存單位為「秒」,之前版本為「分」
Cache::put('key', 'value', $seconds);
// 未設置過期時間將永久有效
Cache::put('key', 'value');
Cache::add('key', 'value', $seconds);
Cache::forever('key', 'value');
Cache::sear('key', function(){ return 'value' });
Cache::remember('key', $seconds, function(){ return 'value' });
Cache::rememberForever('key', function(){ return 'value' });
Cache::forget('key');
Cache::has('key');
Cache::get('key');
Cache::get('key', 'default');
Cache::get('key', function(){ return 'default'; });
// 取到數據之后再刪除它
Cache::pull('key');
// 清空所有緩存
Cache::flush();
Cache::increment('key');
Cache::increment('key', $amount);
Cache::decrement('key');
Cache::decrement('key', $amount);
Cache::tags('my-tag')->put('key','value', $seconds);
Cache::tags('my-tag')->has('key');
Cache::tags('my-tag')->get('key');
Cache::tags(['people', 'artists'])->put('John', $john, $seconds);
Cache::tags('my-tag')->forget('key');
Cache::tags('my-tag')->flush();
Cache::tags(['people', 'authors'])->flush();
Cache::section('group')->put('key', $value);
Cache::section('group')->get('key');
Cache::section('group')->flush();
Cache::tags(['people', 'artists'])->put('John', $john, $seconds);
// 輔助函數
cache('key');
cache(['key' => 'value'], $seconds);
cache(['key' => 'value'], now()->addMinutes(10));
cache()->remember('users', $seconds, function() { return User::all(); });
// 指定緩存存儲
Cache::store('file')->get('foo');
Cache::store('redis')->put('name', 'Jack', 600); // 10 分鐘
// 事件
'Illuminate\Cache\Events\CacheHit' => ['App\Listeners\LogCacheHit',],
'Illuminate\Cache\Events\CacheMissed' => ['App\Listeners\LogCacheMissed',],
'Illuminate\Cache\Events\KeyForgotten' => ['App\Listeners\LogKeyForgotten',],
'Illuminate\Cache\Events\KeyWritten' => ['App\Listeners\LogKeyWritten',],
~~~
- 參考知識--非必學僅供必要時候查詢
- 知識清單
- Composer 安裝等
- artisan--創建模型-控制器-各種模塊
- Route--路由
- Paginate--分頁
- File--文件
- View--視圖
- template--模版
- Model--模型
- Schema--數據表索引-外鍵-字段類型
- DB-基本使用-查詢語句-joins-聚合--原生sql-增刪改查等
- message--消息
- Validation--驗證規則
- Auth-用戶認證-用戶權限
- Helper-數組對象-路徑-字符串-urls-links等
- Session會話
- Response--回應
- Request--請求
- Redirect--重定向
- Environment--環境
- Log--日志
- URL--地址
- Event--事件
- Input--輸入
- Security安全--哈希-加密解密
- Queue--監聽
- Container--容器
- Config--參數設置
- Cache--緩存
- Cookie--設置-獲取--刪除等
- Mail--郵件
- String--字符串
- Collection--集合
- Storage--存儲
- Lang--語言
- 單元測試
- 文件夾結構簡介
- 第一章 laravel8運行環境的搭建(已經有了運行環境的直接跳過)