Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 快取種類
- - database
- 存放於 DB table
- - Memcached
- 記憶體快取
- - Redis
- 簡易概念:
- 1. 當 Cache 存在時,返回 Cache,反之重新取得,寫入 Cache
- 2. Cache 可設置保存時間,過期後清除
- 3. 也可設置永久保存,手動新增、修改、刪除
- QA:
- 1. 如何做到 DB 更新時從 DB 取得,反之從 Cache 取得
- 在 DB 更新時,同步寫入 Cache,讀取一律由 Cache 讀取
- 2. Session 和 Cache 使用上的差別
- Session 主要用於儲存與 User 登入相關的資訊 (private 的緩存)
- Cache 是存放一些與 DB 查詢後相關的資訊,比如不需頻繁查詢的資訊 (public 的緩存)
- 3. 使用 Redis 做 Cache 時, Redis:: 和 Cache:: 的差別
- 實際上跑起來沒有差別,但是使用 Cache:: 可以在未來使用其他模式(Memcached、DB)時只需修改 config 即可轉換
- Redis:: 則需重寫改為 Cache::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement