Cache Writing & Eviction Policies

Cache Writing & Eviction Policies

avatar
FrugalBoy
2025.01.23조회수 4회

Write-Through

Let's start with the simplest writing policy: Write-Through. In this approach, when data needs to be updated, we write it to both the cache and the main database simultaneously. Only when both writes are complete does the system confirm the update. This policy ensures that the cache and database stay perfectly synchronized, making it ideal for systems where data consistency is critical, like financial applications or inventory management. But Write-Through has a significant drawback. Every write operation must wait for both the cache and database updates to complete, which can make write operations slower.


Write-Back

To address the performance limitation of Write-Through, some systems use Write-Back (also called Write-Behind). With Write-Back, data is initially written only to the cache, and the system immediately confirms the update. The modified data is written to the database later, usually in batches. This makes write operations much faster since they don't have to wait for the slower database write. Write-Back is perfect for systems that need high write performance, like real-time analytics or gaming applications. But ...

회원가입만 해도
이 글을 무료로 읽을 수 있어요.

이미 계정이 있으신가요?로그인하기
댓글 0
avatar
FrugalBoy
구독자 5명구독중 11명
Wanna live like a frugal boy For the genetically superior, success is easier to attain. But it is by no means guaranteed. After all, there is no gene for fate -Gattaca-