Insights on Database Caching Approaches

  • When an application needs to fetch the data from the database, it first checks for the data in the cache.
  • If the cache has the data, the cached data is returned to the application. This avoids the unnecessary request being made to the database.
  • If cache misses the data, the database is queried for the data. Then the cache is populated with the data retrieved from the database and the data is returned to the caller.
  • The cache contains only the data that the application requests. This keeps the cache size cost-effective.
  • This approach has immediate performance gains.
  • As the data is loaded into cache only when data is missed in the cache, there will be an overhead in the initial response time for the first request.
  • The occurrence of stale data. As the cache is updated only when there is a cache-miss, the data in the cache becomes stale. This can be overcome using Write-through or Time To Live(TTL) strategies.
  • The backend process or the application updates the database
  • The cache is updated immediately with the latest data.
  • The data in the cache will never be stale, as the cache is updated every time the data is updated.
  • The database read operations are minimized thus improving the performance.
  • As all the data are updated in the cache, the infrequently requested data are also written into cache resulting in cache churn and making the cache larger and more expensive.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Payoda Technology Inc

Payoda Technology Inc


Your Digital Transformation partner. We are here to share knowledge on varied technologies, updates; and to stay in touch with the tech-space.