caching

Cache

緩存更新機制

Write through (都寫啦)

同時寫數db & cache

  • 優點
    1. 完整的數據一制性
    2. 發生系統災難崩潰時不會丟失資料
  • 缺點
    1. 同時寫入db & cache,因此寫的延遲性會偏高

Write around (寫DB)

適合放在寫入後沒有要馬上讀取的地方

  • 優點
    1. 直接寫入db,因此寫得延遲會低一些
    2. 發生系統災難崩潰時不會丟失資料
  • 缺點
    1. 依賴 read-miss 更新緩存

Write-back (寫緩存)

  • 優點
    1. 速度fucking快
  • 缺點
    2. 發生系統災難崩潰時資料8888888

緩存驅逐策略

Cache eviction policies

  • First In First Out (FIFO)
  • Last In First Out (LIFO)
  • Least Recently Used (LRU)
  • Most Recently Used (MRU)
  • Least Frequently Used (LFU)
  • Random Replacement (RR)

Refrence

Author image

About Johnny.Xie

You've successfully subscribed to Johnnnnnny Blog
Great! Next, complete checkout for full access to Johnnnnnny Blog
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.