Cache invalidation
If you do a get operation that populates the cache, then either the cache updates, or invalidation has to take place when PUT/POST/DELETE operations occur that update the data.
If you recollect, we had a cache that held the products corresponding to a category ID. As we add and remove products using the APIs created for inserting, updating, and deleting, the cache needs to be refreshed. Our first preference is to check if we can update the cache entry. However, the business logic of pulling the categories corresponding to the cache is present in the database (through a WHERE clause). Hence, it is best to invalidate the cache containing the relations when a product update happens.
The general assumption for a caching use ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access