Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Write-Through Invalidation | Core Cache Invalidation Patterns
Cache Invalidation Patterns

bookWrite-Through Invalidation

Deslize para mostrar o menu

Write-Through Invalidation

Write-through invalidation is a cache consistency pattern where every write operation is performed on both the cache and the underlying data source at the same time. This ensures that the cache and the database always remain synchronized.

How Write-Through Works Internally

  • When you update or insert data, the change is immediately written to the cache;
  • The same change is then written to the persistent data store (such as a database);
  • The write operation is only considered successful if both the cache and the data store are updated;
  • Reads can be served directly from the cache, which always reflects the latest data.

Performance Trade-Offs

  • Reduced write performance: every write operation incurs the cost of updating both the cache and the data store, which can increase write latency;
  • Read efficiency: reads are fast and efficient because the cache always has the latest data;
  • Simplicity: this pattern is simple to implement and reason about, making it a good choice for systems where consistency is more important than write throughput.

Write-through invalidation is ideal for use cases where data consistency is critical and the system can tolerate slightly slower writes in exchange for fast and reliable reads.

Write-through cache invalidation analogy

Imagine you keep a notebook to quickly look up your friend's phone numbers, instead of searching through your entire contact list every time. Whenever a friend changes their number, you immediately update both your main contact list and your notebook at the same time. This way, your notebook always has the latest, correct information. This is how write-through cache invalidation works: every time you update the data in the main storage, you also update the cache right away, ensuring both are always in sync.

question mark

What best describes the write-through cache invalidation pattern?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 2. Capítulo 2
some-alt